I'm trying to开发者_如何学C compile some code. Here is the error I'm getting:
error while loading shared libraries: libcudart.so.4: cannot open shared object file
Now I've included /usr/local/cuda/include
and linked to /usr/local/cuda/lib
and passed the -lcudart flag on the compile prompt.
Yet I still get this run-time error!
I've just started using Eclipse, and this is really annoying.
Any insight greatly appreciated.
Thanks in advance,
This usually happens with old code when they change the folder structure. Locate where the file is expected in the old code, then make a sym link to where it actually is.
Also try launching eclipse as root. Or running:
ldconfig /usr/local/cuda/lib
By default the runtime linker won't see stuff in /usr/local/cuda/lib. You need to explicitly tell it to look there. There are several methods:
- Set up the
LD_LIBRARY_PATH
environment variable to contain/usr/local/cuda/lib
. - Run
ldconfig /usr/local/cuda/lib
as root. - Add
-rpath=/usr/local/cuda/lib
to your linker arguments (-Wl,-rpath=/usr/local/cuda/lib
if linking withg++
).
I had exactly the same error. I am using eclipse Juno with Cuda under Ubuntu 10.04. The problem was that while I wad already configured the linker path to point to /usr/local/cuda/lib64
(in ~/.bashrc
etc), eclipse still couldn't find it. I could run the compiled (via eclipse) project from terminal, but it couldn't link in eclipse's terminal after trying to Run
.
My solution was to add the variable LD_LIBRARY_PATH
with value /usr/local/cuda/lib64
in File->Properties->Run/Debug Settings->Edit (Selected project)->Environment Tab
I don't know if there's a more permanent solution but it worked for me.
I should also mention that I had already added accordingly some extra variables in the Building Environment (C/C++ Build->Environment
in the properties window) because I couldn't build the project for the same reason.
The only weird thing is that at first it could run without problem and then when I reopened eclipse, this error appeared without me changing anything.
Does the file exist, with the expected name in the right directory? Does the symlink (I assume you have one pointing to the versioned .so) point to the right, and a valid, shared object? Do you have read permissions for that file?
Now, you say this is a runtime error while trying to compile the code. Do you mean you can compile, then when you run the error occurs, or the error happens when you try to run the compiler (a linker error)?
精彩评论