Skip to content Skip to sidebar Skip to footer

Ld Can't Link With A Main Executable

On OSX 10.6.4 with i686-apple-darwin10-g++-4.2.1 compiling using TextMate and a Makefile which in the first place has been made für a Linux and I am trying to translate for OSX. W

Solution 1:

The error message is telling you the problem—it is that /usr/local/lib/libxrlTUB.so is not a shared library; it's an executable. You can't link against an executable. Probably whatever build process you used for libxrlTUB.so didn't understand how to build shared libraries on the Mac (it's more suspect because .dylib is the correct extension to use.)

Take a look at Apple's documentation on compiling dynamic libraries. You can use file to make sure your output is of the correct type, for example:

% gcc -c foo.c% gcc -dynamiclib foo.o -o foo.dylib% file foo.dylib
foo.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Without -dynamiclib you end up with an executable, which may be the problem you've run into.

Post a Comment for "Ld Can't Link With A Main Executable"