【发布时间】:2012-10-26 04:10:54
【问题描述】:
我对 cmake 完全陌生。在 svn 更新后(还有 binutils,我怀疑这是导致问题的原因),我收到一个错误(我之前成功编译并使用过该程序)
Linking CXX executable gmsh
/usr/bin/ld: /usr/local/lib/liblapack.a(dgesvd.o): undefined reference to symbol '_gfortran_concat_string@@GFORTRAN_1.0'
/usr/bin/ld: note: '_gfortran_concat_string@@GFORTRAN_1.0' is defined in DSO /usr/lib/libgfortran.so.3 so try adding it to the linker command line
/usr/lib/libgfortran.so.3: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [gmsh] Error 1
make[1]: *** [CMakeFiles/gmsh.dir/all] Error 2
make: *** [all] Error 2
也许和这个Fedoraproject DSO Change有关?
我有一个最新的 archlinux (binutils-2.23-1)。
我尝试在ccmake . 菜单中编辑行。点击 [c] 后,原始选项被恢复(所以我不能将/usr/lib/libgfortran.so.3 添加到GMSH_EXTERNAL_LIBRARIES 变量中,以便[g] generate 新的Makefiles)。
我也尝试添加了一些 cmake irc 聊天中推荐的选项,但最终没有奏效。
cmake . -DCMAKE_LINK_FLAGS=-Wl,--add-needed
或
cmake . -DCMAKE_LINK_FLAGS=-lgfortran
导致同样的错误。我能做什么?
补充资料:make VERBOSE=1pastebin link
【问题讨论】:
-
你试过
cmake . -DCMAKE_LINK_LIBRARY_FLAG=gfortran吗? -
@Fraser 我刚刚尝试过,但它会产生完全相同的错误。我想我需要实现的只是将
-lgfortran添加到ld调用中。 -
这通常可以通过在适当的 CMakeLists.txt 中将
gfortran添加到target_link_libraries调用来实现 -
@Fraser 如果您将此作为答案,我会接受它,因为它有效!
target_link_libraries(gmsh ${LINK_LIBRARIES} gfortran)
标签: linker cmake shared-libraries ld