涉及cmake的建筑项目,我如何使它意识到图书馆 [英] Building project involving cmake, how do I make it aware of libraries
问题描述
当我尝试使用cmake和gcc在64位linux(debian)机器上构建此项目时,我从链接器收到错误:
When I try to build this project with cmake and gcc on a 64-bit linux (debian) machine, I get an error from the linker:
Linking C executable ../../../../cpsadamsx
/home/dala/lib64/libSimTKcommon.so: undefined reference to `dlopen'
/home/dala/lib64/libSimTKcommon.so: undefined reference to `dlclose'
/home/dala/lib64/libSimTKcommon.so: undefined reference to `dlerror'
/home/dala/lib64/libSimTKcommon.so: undefined reference to `dlsym'
collect2: ld returned 1 exit status
make[2]: *** [cpsadamsx] Error 1
make[1]: *** [sundials/examples/cpodes/serial/CMakeFiles/cpsadamsx.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
显然,dlopen,dlclose,dlerror和dlsym是对libdl.so的引用。我有这个库在/lib64/libdl.so.2,但为什么它没有找到?
Apparently dlopen, dlclose, dlerror and dlsym are references to libdl.so. I have that library in /lib64/libdl.so.2, but why is it not found?
它是一个正常的'./configure;使; make install'-path我可以设置LIBS变量并发出configure命令(我想):
Would it have been a normal './configure; make; make install'-path I could have set the LIBS variable and issued the configure command like this (I think):
export LIBS=-ldl && ./configure
但是我该怎么办呢?
UPDATE:
因此,似乎找到了(或至少一个)库,但不包含有问题的符号。也许它尝试与/ lib中的32位库?
So it seems that the (or at least a) library is found, but does not contain the symbols in question. Perhaps it tries with the 32-bit library in /lib?
有一个反汇编/lib64/libdl.so.2的方法,以确保它有参考dlopen等?
Is there a way to disassemble /lib64/libdl.so.2 to make sure it does have the references dlopen etc?
现在的问题似乎指导构建工具到正确的版本库。
The problem now seems to guide the build tools to the correct version of the library.
推荐答案
由于这个问题显示在google上,两个答案都不会指向这里的正确解决方案:
As this question is showing up on google and both answers won't point to the correct solution here it is:
CMakeLists.txt添加 $ {CMAKE_DL_LIBS}
以链接到idl。
看起来应该类似:
In your CMakeLists.txt add ${CMAKE_DL_LIBS}
to link against idl.
It should look similar to this:
target_link_libraries(ExpandableTest
${CMAKE_DL_LIBS}
Expandable
ExpandableTestLibrary
)
这篇关于涉及cmake的建筑项目,我如何使它意识到图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!