How to use the include and link directories in CMakeLists.txt for arm64

I am trying to integrate a third party software into my torizon project. For “build amd local”, my project was fine. I was able to run the container in Ubuntu successfully.
But when I ran the contain for arm64, it could not find the lib files.

/usr/bin/ld: cannot find -ltps_A: No such file or directory
/usr/bin/ld: cannot find -ltps_B: No such file or directory

where libtps_A.a and libtps_B.a (and .so files) are in /home/testtps/lib/.

I have following in my CMakeLists.txt:

include_directories(
/home/testtps/include
)
link_directories(
/home/testtps/lib/
)
target_link_libraries(hometpsarm PRIVATE
tps_A
tps_B
rt
pthread

}

for rt and pthread, I added libc6-dev in the Dockerfile for “apt install”.

I guess maybe I missed something, What should I do to solve this linking problem?
Thanks.

Greetings @matty,

The error message provided says “No such file or directory”. Can you confirm whether that is actually accurate or not? Are these library files at the locations in the container expected by the compiler?

Also how exactly did you include these third party libraries in the container?

I think I have an idea of what you might have done wrong. First of all keep in mind you need to make sure these files are available in the “correct” container. The container that compiles your code is not the same as the container that runs your code.

There is an intermediary container the “SDK container” that builds your code first. Then the compiled output is copied into the final application container. If you’re copying your libraries into the application container then they would not be available in the SDK container.

Looking at what you have here you’re telling the compiler your third-party libraries are in /home/testtps/lib. But, if you look at the task for build-debug-arm64 you can see how it works: vscode-torizon-templates/cmakeConsole/.vscode/tasks.json at dev · toradex/vscode-torizon-templates · GitHub

It runs the SDK container by bind-mounting the entire project workspace to ${config:torizon_app_root}" which defaults to /home/torizon/app in the container via your project’s setting.json. This is how your project’s source code is made available in the SDK container for compiling.

For example, imagine in your project you have your third-party libraries in the location of <project-folder>/lib. Then in the SDK container via this bind-mount they would be at /home/torizon/app/lib I believe. Keep that in mind when trying to work out the path that you should pass to the compilier via CMake.

For “build amd local”, my project was fine. I was able to run the container in Ubuntu successfully.

One final note, if you’re running the task build-debug-amd64-local. Then I don’t think this is being compiled or ran in a container. At least going by the definition of the task in tasks.json. This just compiles and runs your code locally using the tools on your machine. So it’s not quite comparable to the usual container workflow.

Best Regards,
Jeremias

Thanks.

Problem was solved today. It seems my files in container were missing. After I put all needed files in container, my program was fine.

Problem was solved today. It seems my files in container were missing. After I put all needed files in container, my program was fine.

Good to hear you were able to resolve the issue.