Search code examples
c++linkerclangllvmllvm-gcc

Undefined reference to .. error (Linux) - Compiles fine in OSX


Have wasted almost full 4 days trying to compile this package. It compiles fine in OSX 10.6, but gives Undefined reference errors when I try to compile it on a linux (Kubuntu 10.04, 3.8.0.27 kernel) machine.

The error seem to be that the makefiles are ordered wrong, but AFAIK, I am the only one having trouble compiling it. So I'm trying to find what's making the difference. The software package is quite big and editing the Makefiles and moving 30-50 libraries here and there doesn't seem like a good idea.

Here's the differences I think I found so far

  • Compiler - gcc-4.7 (Linux) and llvm-gcc-4.2 (OSX)
  • Compiler flags --shared (Linux) and -dynamic -dynamiclib -undefined dynamic_lookup (OSX)

Anyone have any suggestions?

  1. I tried using clang++ and llvm-gcc-4.7 as the compiler, but I think it still used the same linker (ld?). So I could try to specify to use llvm? How do I do that?

  2. is --shared flag somehow different from the dynamic -dynamiclib -undefined dynamic_lookup flags in OSX?

  3. Does the linux kernel or distribution matter? (I think they compiled it fine on a CentOS machine)

Please help. Thanks a lot.


Solution

  • Compiled it with gcc 4.4 and worked flawlessly. I guess the order doesn't matter on 4.4 for the given package.