I am trying to compile an application that will run on a Colibri i.MX7 with Linux BSP5.7 that is customized via Yocto.
After successfully compiling and running a simple “hello world” program, I’m now compiling the “real” application that I want to run.
This application is using sockets to implement a TCP server.
As you can see from the ld command line, the root directory for libraries is /opt/tdx-xwayland/5.7.1/sysroots/armv7at2hf-neon-tdx-linux-gnueabi . The contents of this directory are generated by Yocto (bitbake tdx-reference-minimal-image -c populate_sdk) and installed from oe-core/build/deploy/sdk/ by running the .sh file in that directory.
As far as I know, the socket API is supposed to be in one of the default libraries that ld will use but apparently this is not the case. Can anyone tell me which library to add in order to include the socket API ? Or alternatively, why the socket API is not present in the standard libraries…
Thanks for your reply.
I already found the post you mentioned but it did not solve my problem. First of all, there is no -nostdlib option to the linker.
I did however try to add the libraries suggested in the post but that did not help.
Hi @henrique.tx,
Not sure that I will be able to do this easily. I’m quite new to Yocto and while already having some issues with the building of my image, I would like to avoid adding additional complexity for now. Especially because the application consists of several files in multiple directories.
However, I realized that one of the differences between my “real” application and the “hello world” example is the fact that my applicant is a C++ program, which possible changes some naming conventions for functions.
To confirm that, I added some calls to socket related functions (socket(), setsockopt(), bind(), etc.) to the “Hello world” program and compiled and ran it without problems.
=> So the problem is C++ naming I guess
(the application used to compile and run when I used Visual Studio code + Docker on Torizon, but that was before I had to abandon Torizon because of lack of RPMsg/OpenAMP support…)
I did a try by adding ‘extern “C”’ in the socket.h file (in the SDK generated by Yocto, and installed under /opt/tdx-xwayland/5.7.1/sysroots/armv7at2hf-neon-tdx-linux-gnueabi/usr/include/sys, but without any changes in the error message.
Next step was to add my own definition of socket() to the .cpp file and not the linker does not complain about socket anymore but is missing symbol symbol ‘strcpy@@GLIBC_2.4’.
I finally solved the problem in a quite unexpected way. Earlier on, I modified the SDK environment setup file (the one that is executed before starting eclipse, i.e. /opt/tdx-xwayland/5.7.1/environment-setup-armv7at2hf-neon-tdx-linux-gnueabi in my case) because the linker complained about unrecognized options (-Wl, O1 for example).
Looking deeper in the cause of this, I learned that the -Wl prefix is used to pass linker option to gcc/g++. In my eclipse project, I specified ${LD} as the linker command. => Changing that to ${GXX} not only solved the options problem but also the missing symbols