Undefined reference to symbol 'socket@@GLIBC_2.4'

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 :slight_smile:

This post is therefore solved.

Jeroen