views:

197

answers:

1

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.

A: 

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?

Douglas Leeder
I doubt that the parent OS's header files are being included (-qnolib and -qnostdinc are equivalent for xlc/xlC). I did run nm against libc.a under the included library directories and all the symbols were found. Good suggestions, unfortunately, already tried.
bogertron
I suggest running nm against the object files, to find out the real symbols that are being looked for - the ones listed by xlc look like the demangled versions of C++ references.
Douglas Leeder