构建时如何将链接器指向临时路径?
上下文:链接到尚未安装但将来会安装的库
...
set(LIBS_TO_BE_INSTALLED)
libA.so
libB.so
)
set(FUTURE_LIB_PATH
/usr/lib/future/path
) # Libraries are found here if installed
set(TEMPORARY_LIB_PATH
/temporary/path
) # Libraries are found here before installing
add_library(${PROJECT_NAME} SHARED $SRCS $HDRS)
link_directories(AFTER $FUTURE_LIB_PATH) #this works if libs are installed
target_link_libraries(${PROJECT_NAME} ${LIBS_TO_BE_INSTALLED})
...
ldd
输出应该是什么样子:
$ ldd ${PROJECT_NAME}.so
...
libA.so.X => /usr/lib/future/path/libA.so.X
libB.so.Y => /usr/lib/future/path/libB.so.Y
...
但是,当尝试使用临时路径时,它不起作用:
link_directories(AFTER $TEMPORARY_LIB_PATH)
失败,出现错误:
[100%] Linking CXX shared library ${PROJCET_NAME}.so
/usr/bin/ld: cannot find -llibA: No such file or directory
/usr/bin/ld: cannot find -llibB: No such file or directory
1条答案
按热度按时间wgmfuz8q1#
找到了答案
ldd
output before future libraries are installed: