简体   繁体   中英

OS X dylib refers to the executable itself

I'm not sure if I'm asking this question the right way, but I have recently tried to make an application that uses mysql/c++

I compile the program like this:

g++ -o test main.cpp -I./include -L./lib -lmysqlclient -lmysqlcppconn

and when I run the program it responds the following:

dyld: Library not loaded: /home/myname/Desktop/path/to/exe
  Referenced from: /Users/myname/Desktop/path/to/./test
  Reason: image not found
Trace/BPT trap: 5

Can anyone seee what I might be doing wrong?

Thanks in advance, and let me know if more info about the problem is needed.

I can only guess your mysql libraries are not located in a standard place.
If you want to keep your libraries in a non standard place, you should set the environment variable DYLD_LIBRARY_PATH to point to your dynamic link libraries.
Under linux/most unices that would be LD_LIBRARY_PATH .

So something like:

export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:./lib";
./yourExecHere

Should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM