Question

I am attempting to cross-compile on AIX with the xlc/xlC compilers.

The code compiles successfully when it uses the default settings on another machine. The code actually successfully compiles with the cross-compilation, but the problem comes from the linker. This is the command which links the objects together:

$(CHILD_OS)/usr/vacpp/bin/xlC -q32 -qnolib -brtl -o $(EXECUTABLE) $(OBJECT_FILES)   
-L$(CHILD_OS)/usr/lib  
-L$(CHILD_OS)/usr/vacpp/lib/profiled  
-L$(CHILD_OS)/usr/vacpp/lib  
-L$(CHILD_OS)/usr/vac/lib  
-L$(CHILD_OS)/usr/lib  
-lc -lC -lnsl -lpthread  
-F$(CHILD_OS)$(CUSTOM_CONFIG_FILE_LOCATION)

When I attempt to link the code, I get several Undefined symbols: .setsockopt(int,int,int,const void*,unsigned long), .socket(int,int,int), .connect(int,const sockaddr*,unsigned long), etc.

I have discovered that the symbols missing are from the standard c library, libc.a. When I looked up the symbols with nm for the libc.a that is being picked up, the symbols do indeed exist. I am guessing that there might be a problem with the C++ being unable to read the C objects, but I am truly shooting in the dark.

Was it helpful?

Solution

Sound like it might be a C++ name mangling problem.

Run nm on the object files to find out the symbols that they are looking for. Then compare the exact names against the libraries.

Then check the compilation commands, to ensure that the right version of the header files is being included - maybe it's including the parent OS's copy by mistake?

OTHER TIPS

I was eventually able to get around this. It looks like I was using the C++ compiler for .c files. Using the xlc compiler instead of the xlC compiler for C files fixed this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top