开发者

OS X runtime linker finding wrong version of lib

I have a C++ shared library being called from my Python program. The C++ lib is compiled with HDF5 which I installed using homebrew on OS X, so it resides in /usr/local/lib. Now the problem is that I also have PyTables installed, which includes an older version of libhdf5, installed somewhere in /Library/Frameworks/EPD64.framework/Versions/Current/...

I can compile and link my library just fine, and otool -L indeed points to /usr/local/lib/libhdf5.dylib. However, when I try to run it from P开发者_如何学编程ython, there is a version mismatch error. Somehow the runtime linker is loading the older hdf5 library instead.

One workaround is to build hdf5 as a static library instead, but I'd like to find a neater solution - how can I persuade the runtime linker to use the newer library? I already tried setting DYLD_LIBRARY_PATH but that just broke everything else (Python and MacVim wouldn't start).


Can you provide more info? I have a few alternatives (and questions).

If I understood correctly, you have a library that uses lib_ver_a.dyld and pyTables that uses lib_ver_b.dyld. I.e. the same library but different version.

You could either:

  1. Compile your library to use the same version as pyTables (DYLD_LIB... while you compile) and run your program with pyTables library: DYLD_LIBRARY_PATH=/correct/path/lib python myprog.py

  2. Upgrade your xcode (which version you have? also which osx version?). This upgrades your libraries and pyTables (be careful, newest is not necessary the most stable)

You should also check which python you are calling (a custom one or apple one).

There is also a possibility to define a specific dyld while linking (Do you use gcc or ld for linking? I might miss some options here):

gcc /path/lib1.dyld myLib.c -o myLib.o

This way your library is linked to certain version of the library (caution! I don't remember the exact details, but I can dig them out).

I hope this helps.

br,

Juha

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜