6

When I compile .cu file with nvcc 5.0, the compiler gives me following information.

/usr/bin/ld: skipping incompatible /usr/local/cuda-5.0/lib/libcudart.so when searching for -lcudart

It seems either a warning or an error. I don't know what the matter is.

Is there anyone knowing more details about this information?

konjac
  • 757
  • 8
  • 14
  • Are you trying to compile a 64-bit code? If so, you need to link against the 64-bit version which must be located in `/usr/local/cuda-5.0/lib64/libcudart.so`. – BenC Jun 13 '13 at 06:14

1 Answers1

11

This warning often happens when trying to link a 64-bit code with a 32-bit library, see this question: Skipping Incompatible Libraries at compile.

You need to distinguish 2 library files:

  • $CUDA_HOME/lib/libcudart.so, the 32-bit version of the cudart library.
  • $CUDA_HOME/lib64/libcudart.so, the 64-bit version of the cudart library.

(in your case, $CUDA_HOME is /usr/local/cuda-5.0)

Basically, the linker finds the 32-bit library first (-L options are searched in order) and returns that warning even if it ends up finding the proper library.

You probably need to add $CUDA_HOME/lib64 to your LD_LIBRARY_PATH environment variable before $CUDA_HOME/lib so that ld can find the proper library for your 64-bit architecture before the 32-bit version.

Community
  • 1
  • 1
BenC
  • 8,729
  • 3
  • 49
  • 68
  • 1
    Thank you. My working OS is 64-bit, so all my code will be compile and link to 64-bit. It seems strange that the 64-bit CUDA5.0 includes 32-bit librarys. – konjac Jun 13 '13 at 06:26
  • 1
    On a 64-bit OS, you can also make and run 32-bit applications, so you'd need the 32-bit `libcudart.so` for that. – BenC Jun 13 '13 at 06:36
  • 1
    I seem to have precisely the same problem. My `LD_LIBRARY_PATH` has `lib64` before `lib`, so that doesn't seem to work on my system. Any ideas? – Zoë Clark Sep 23 '13 at 22:51
  • @ZoëClark: just to be sure, this warning does disappear if you remove the `lib` path from your `LD_LIBRARY_PATH`, right? – BenC Oct 03 '13 at 09:38