2012-11-06 226 views
1

我完全是cmake的新手。一個svn更新後(也binutils的,我懷疑這是造成這個問題),我得到一個錯誤(我成功地編譯和之前所使用的程序)CMAKE DSO鏈接

Linking CXX executable gmsh 
/usr/bin/ld: /usr/local/lib/liblapack.a(dgesvd.o): undefined reference to symbol '[email protected]@GFORTRAN_1.0' 
/usr/bin/ld: note: '[email protected]@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變量中,以便按照新的Makefiles的順序[g] generate)。

我也試過在cmake irc chat中加入一些推薦的選項,但最終沒有奏效。

cmake . -DCMAKE_LINK_FLAGS=-Wl,--add-needed 

cmake . -DCMAKE_LINK_FLAGS=-lgfortran 

在相同的誤差引起。我能做什麼?

其他信息:make VERBOSE=1pastebin link

+0

你試過'cmake。 -DCMAKE_LINK_LIBRARY_FLAG = gfortran'? – Fraser

+0

@Fraser我剛剛嘗試過,但它產生完全相同的錯誤。我想我所需要做的就是在'ld'調用中加入'-lgfortran'。 – Sebastian

+0

這通常可以通過在適當的CMakeLists中向['target_link_libraries'](http://www.cmake.org/cmake/help/v2.8.10/cmake.html#command:target_link_libraries)調用添加'gfortran'來實現.txt – Fraser

回答

4

要將庫添加到鏈接命令,你可以使用target_link_libraries。顯然在這種情況下,你想:

target_link_libraries(gmsh ${LINK_LIBRARIES} gfortran)