建设项目涉及cmake的,我该如何使它意识到库
的。当我尝试建立这个项目的cmake和gcc在64位Linux(debian的)机器,我得到一个错误的链接:建设项目涉及cmake的,我该如何使它意识到库
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中有该库,但为什么找不到?
它会是一个正常的'./configure;使;使install'路径我可以设置LIBS变量,并发出这样的configure命令(我认为):
export LIBS=-ldl && ./configure
但我怎么现在就这样做?
UPDATE:
这样看来,(或至少一个)库被发现,但不包含有关的符号。也许它尝试在/ lib中的32位库?
有没有方法反汇编/lib64/libdl.so.2,以确保它确实有引用dlopen等?
现在的问题似乎是指导构建工具正确版本的库。
中的CMakeLists.txt添加这一点,它应该工作:
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ldl")
这是linux特有的,而不是最好的解决方案,请参阅上面的CMAKE_DL_LIBS参考。 – ideasman42 2013-08-30 20:50:39
由于这个问题是显示在谷歌起来,两个答案赢取” t指向正确的解决方案:
在你的CMakeLists.txt中添加${CMAKE_DL_LIBS}
来链接idl。 应该类似于此:
target_link_libraries(ExpandableTest
${CMAKE_DL_LIBS}
Expandable
ExpandableTestLibrary
)
这是更兼容的anwser,应该是公认的。 – 2012-09-26 02:15:02
我想补充一点,我必须将$ {CMAKE_DL_LIBS}移动到列表中的最后一个位置。否则它不适合我 – Anonymous 2014-07-09 18:09:07
可能的工作,但它不是“我”的项目,所以最好我不想编辑的CMakeLists.txt文件。 – dala 2009-08-13 21:16:47