当我尝试在 64 位 linux (debian) 机器上使用 cmake 和 gcc 构建此项目时,我从链接器中收到错误:
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; 吗?制作; make install'-path 我可以设置 LIBS 变量并发出这样的配置命令(我认为):
export LIBS=-ldl && ./configure
但我现在该怎么办呢?
UPDATE:
因此,似乎找到了(或至少一个)库,但不包含有问题的符号。也许它会尝试使用 /lib 中的 32 位库?
有没有办法反汇编 /lib64/libdl.so.2 以确保它确实具有引用 dlopen 等?
现在的问题似乎是引导构建工具使用正确的库版本。
由于这个问题出现在谷歌上,并且两个答案都不会指向正确的解决方案,因此:
在你的 CMakeLists.txt 添加${CMAKE_DL_LIBS}
链接到idl。
它应该类似于:
target_link_libraries(ExpandableTest
${CMAKE_DL_LIBS}
Expandable
ExpandableTestLibrary
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)