If i want to build a c application on an apalis module in a dockercontainer. Like: https://developer.toradex.com/torizon/5.0/application-development/ide-extension/programming-languages/ccpp-development-and-debugging-on-torizoncore-using-visual-studio-code/
I have an existing project was created as a remote project for a ‘normal’ Linux system in visual studio.
I would now like to port this to our apalis module.
Regarding CMake I’m completely unsure.
It would be nice to see an example project for a project with the following simple folder structure.
│ ├── CMakeLists.txt
│ ├── more_a.c
│ ├── more_a.h
│ ├── more_b.c
│ └── more_b.h
or do you get this error message:
[build] /usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: cannot find -lS2LP
fixed via dockerconfiguration?
the S2LP folder is included via target_link_libraries, …
sorry I am no expert in CMake, but I think I can give you some general hints how to solve this issue.
gnu/bin/ld: cannot find -l<NAME> typically indicates that the linker wants to link the library with name
NAME and it does not find. Now you have several options:
- make sure the library file (either a .so or a .a file) exsits within your docker container
- If it does not exist, maybe you can install it with a package manager like
- If it does exists, maybe you just need to add the path where it is located to the linker. Cmake has a function for this: link_directories — CMake 3.27.1 Documentation
I did a quick google search and was not able to find a package you can instal with this name, so I guess if you do not have precompiled binaries for it, the only option is to build it by yourself and then link your application against these.
Is this the library you are using? GitHub - benwaffle/S2LP: Official S2LP library from the S2LP DK.
I may have expressed myself unclearly.
the S2LP library not found is just the source files in a subfolder.
Another idea would be, to add :
install(TARGETS myLibrary DESTINATION lib)
to the top CMakeLists.txt
I keep trying
Thank You @n11ThoMumme
Just to clarify your situation. So you have a multi-level CMake project as seen by your folder structure. This S2LP library is built in one folder and is then linked and used in the compilation of your main application, correct?
But for whatever reason this linking isn’t working. Now is it not working because S2LP isn’t being built? Or it is being built but it’s not being found?
Also, as a sanity check outside of the VSCode extension if you manually just run cmake and make on this project does it build fine? This would help tell us if the CMake files need adjusting or something is wrong with the build automation in our extension.
Hi @jeremias.tx ,
as indicated, an existing, working project is to be ported.
I found that in VSCode + Torizon Extension you can create a CMake project that already uses a library. This is closest to the answer I wanted.
It is certainly not in the spirit of the inventor of CMake to change the folder structure for each hardware target.
Nevertheless, I’m getting ahead and I consider the thread as answered.
Glad you were able to progress.