Sebastian
Sebastian

Reputation: 1438

CMAKE DSO linking

I'm totally new to cmake. After an svn update (but also to binutils and I suspect this is causing the problem), I get an error (I successfully compiled and used the program before)

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

Maybe it's related to this Fedoraproject DSO Change?

I have an up-to-date archlinux (binutils-2.23-1).

I tried to edit lines in the ccmake . menu. After hitting [c] the original options are restored (so I cannot add /usr/lib/libgfortran.so.3 to the GMSH_EXTERNAL_LIBRARIES variable in order [g] generate the new Makefiles).

I also tried adding some options which were recommended in the cmake irc chat, but it eventually didn't work.

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

or

 cmake . -DCMAKE_LINK_FLAGS=-lgfortran

Resulting in the same error. What can I do?

Additional information: make VERBOSE=1 pastebin link

Upvotes: 1

Views: 3037

Answers (1)

Fraser
Fraser

Reputation: 78330

To add a library to the link command, you can use target_link_libraries. Apparently in this case you want:

target_link_libraries(gmsh ${LINK_LIBRARIES} gfortran)

Upvotes: 4

Related Questions