I'm trying to link jsoncpp (lib_json) with a c++ project using cmake. It works perfectly fine on one computer, but on another one (with pretty much the same config) i get an error when i execute my app :
dyld: Library not loaded: buildscons/linux-gcc-4.2.1/src/lib_json/libjson_linux-gcc-4.2.1_libmt.dylib
Referenced from: path to executable
Reason: image not found
Any idea what might be causing this ? I don't even understand why it tries to look @ buildscons/linux-gcc-4.2.1/src/lib_json/libjson_linux-gcc-4.2.1_libmt.dylib since i put jsoncpp in usr/lib/ and changed the name to libjsoncpp and cmake find the correct path/library.
I also built jsoncpp the exact same way on both computers.
I had the same problem. If you run
tool -L libjson_linux-gcc-4.2.1_libmt.dylib
you can see some weird relative address to yourlibjson...
. I guess if you replicated this directory structure it would work but that's a bad solution.What I did instead is that I used
.a
(libjson_linux-gcc-4.2.1_libmt.a
) and linked it staticaly with my binary. In XCode simply underBuild Settings
->Linking
->Other Linker Flags
I added absolute path to my.a
. For me it was/Users/martin/Downloads/jsoncpp-src-0.5.0/libs/linux-gcc-4.2.1/libjson_linux-gcc-4.2.1_libmt.a
and that's all.Of course, I don't know your use case, maybe you really need to link it dynamically.