I normally use
gcc for both compiling and linking, so I don't need to learn the ld versions of any options that need to be given to both. But at the moment I don't recall the gcc option syntax for selecting output as a .so
I think the ld option
-m elf_i386 corresponds to the gcc option
-m32 so try
/usr/bin/ld -m elf_i386 -shared -o test.so test.o
Quote:
Originally Posted by flighta
if compile it without -m32 then the link is OK
|
Does that mean your .c file is completely self contained (doesn't use any library functions)? Or does it mean ld is finding the right libraries by default? If the latter, I wonder if that also is configured only for 64 bit on your system.
So in addition to getting ld to write the correct format using
-m elf_i386, you might also need additional options to get it to read the right libraries.
I don't use ld directly much, and when I do it doesn't include the right libraries by default, so I need to explicitly include the libraries. I'm used to using the gcc command for linking and gcc is properly configured to include the right default libraries when linking.