lapack icon indicating copy to clipboard operation
lapack copied to clipboard

Linking error while building LAPACK 3.8.0 with MinGW-W64 8.1.0

Open jdx-gh opened this issue 6 years ago • 1 comments

[  3%] Linking Fortran shared library ../bin/liblapack.dll
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(string_intrinsics.o):(.text$__gfortran_concat_string+0x0): multiple definition of `_gfortran_concat_string'
../lib/libblas.dll.a(d000008.o):(.text+0x0): first defined here
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(string_intrinsics.o):(.text$__gfortran_string_len_trim+0x0): multiple definition of `_gfortran_string_len_trim'
../lib/libblas.dll.a(d000038.o):(.text+0x0): first defined here
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$__gfortran_transfer_integer_write+0x0): multiple definition of `_gfortran_transfer_integer_write'
../lib/libblas.dll.a(d000058.o):(.text+0x0): first defined here
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$__gfortran_transfer_character_write+0x0): multiple definition of `_gfortran_transfer_character_write'
../lib/libblas.dll.a(d000053.o):(.text+0x0): first defined here
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$__gfortran_st_write+0x0): multiple definition of `_gfortran_st_write'
../lib/libblas.dll.a(d000032.o):(.text+0x0): first defined here
c:/Tools/MinGW-W64/i686-8.1.0-win32-sjlj-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$__gfortran_st_write_done+0x0): multiple definition of `_gfortran_st_write_done'
../lib/libblas.dll.a(d000033.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make[2]: *** [bin/liblapack.dll] Error 1
make[1]: *** [SRC/CMakeFiles/lapack.dir/all] Error 2
make: *** [all] Error 2 

Everything is fine when LAPACK is built with MinGW-W64 6.3.0. One significant difference I have noticed is that 8.1.0 has only static libgfortran, while 6.3.0 has both, and shared version is used by default.

jdx-gh avatar Nov 20 '18 20:11 jdx-gh

Verified this issue with MinGW 8.1.0 and LAPACK 3.9.0. Found a solution here.

After running CMake, open the SRC\CMakeFiles\lapack.dir\link.txt in the build directory

Add the following sentence as an option of x86_64-w64-mingw32-gfortran.exe: -Wl,--allow-multiple-definition

Just paste it at the end, was a long line in the third line of the link.txt file.

JohnLErvin avatar Jun 11 '20 16:06 JohnLErvin

Solution in https://github.com/Reference-LAPACK/lapack/issues/305#issuecomment-642780550

weslleyspereira avatar May 24 '23 16:05 weslleyspereira

@weslleyspereira I don't get why this has been closed. This should be fixed from within Lapack repository cmake configuration. Not by letting the user fix a bad build configuration.

For other people passing by here. Do not modify link.txt that is a file generated by cmake and should not be modified manually. Prefer instead setting CMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-multiple-definition". You can do it from command line or cmake-gui

Full command line example : cmake -G "MinGW Makefiles" -S lapack -B build_lapack -D BUILD_SHARED_LIBS=ON -D CMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-multiple-definition"

atsju avatar Mar 05 '24 17:03 atsju