Tôi có một dự án lớn (tương đối) C++ để biên dịch và chạy tốt trên ubuntu (sử dụng cmake/catkin). Nó biên dịch tốt trên mac os, nhưng khi cố gắng để bắt đầu thực thi, tôi nhận được thông báo lỗi:Hệ điều hành MAC: thư viện được liên kết động không được tìm thấy mặc dù đường dẫn chính xác
dyld: Library not loaded: <name of library>.dylib
Referenced from:
<path to executable>/<executable>
Reason: image not found
Khi chạy lệnh:
otool -l <executable> | grep LC_RPATH -A2
tôi nhận được kết quả:
cmd LC_RPATH
cmdsize 64
path <correct absolute path to folder containing library> (offset 12)
cmd LC_RPATH
cmdsize 24
path /sw/lib (offset 12)
cmd LC_RPATH
cmdsize 32
path /usr/X11/lib (offset 12)
cmd LC_RPATH
cmdsize 32
path /opt/local/lib (offset 12)
cmd LC_RPATH
cmdsize 32
path /opt/X11/lib (offset 12)
Tôi không rõ vì sao thư viện không được tìm thấy. Chạy:
otool -L <executable>
in:
<executable name>:
<library name>.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/opt/X11/lib/libglut.3.dylib (compatibility version 13.0.0, current version 13.0.0)
/opt/X11/lib/libGL.1.dylib (compatibility version 1.2.0, current version 1.2.0)
/opt/X11/lib/libGLU.1.dylib (compatibility version 1.3.0, current version 1.3.0)
/opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
mà dường như để khẳng định nó không có được con đường đúng đắn.
Mọi thứ tôi bị thiếu?
ps:
không chắc chắn đó là, ở đây các lệnh liên quan cmake tôi đã sử dụng: (từ here)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/${MACHTYPE}")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib/${MACHTYPE}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/${MACHTYPE}")
ENDIF("${isSystemDir}" STREQUAL "-1")
Bạn đang sử dụng Xcode? Nếu vậy, nó trông như thế nào ở đây: Xcode> project> target> Build phase> Link Libraries ... Ngoài ra, Xcode> target> Build Settings ... Ở đây có nhiều liên kết thư viện khác nhau –
Tôi liên kết với các thư viện được biên dịch trong dự án, sau khi cài đặt trong thư mục $ {CMAKE_INSTALL_PREFIX}/lib/$ {MACHTYPE} – Vince
Đầu ra của 'otool -D .dylib' ở vị trí đã cài đặt của nó là gì? –
sakra