Help us understand the problem. What is going on with this article?

MinGWとCmakeを使ってlapackをソースからビルドする時に見た地獄  Hell to build lapack using MinGW and CMake

生じた問題 Occurred Problem

下記のサイトに従ってlapack3.8.0をビルドを試みた。
  I tried to build lapack 3.8.0 according to the instructions of the site below.
LAPACK for Windows "Build Instructions to create LAPACK and LAPACKE 3.5.0 dlls for Windows with MinGW"

サイトに記載の8つ目の指示でlapack.dllが完成されるはずだった。
  The lapack.dll was supposed to be completed with the 8th instruction described on the site.

cmd.exe
buildfolder>C:/MinGW/bin/mingw32-make.exe

しかし次のようなエラーが生じた。
  However, the following error occurred.

cmd.exe
[  7%] Built target blas
[  8%] Linking Fortran shared library ..\bin\liblapack.dll
C:/MinGW/bin/../lib/gcc/x86_64-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:/MinGW/bin/../lib/gcc/x86_64-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:/MinGW/bin/../lib/gcc/x86_64-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:/MinGW/bin/../lib/gcc/x86_64-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:/MinGW/bin/../lib/gcc/x86_64-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:/MinGW/bin/../lib/gcc/x86_64-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
mingw32-make[2]: *** [SRC\CMakeFiles\lapack.dir\build.make:27686: bin/liblapack.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:163: SRC/CMakeFiles/lapack.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2

上記のエラーはシンボルの多重定義に起因するものと思われる。
  The above errors seem to be caused by overloading of symbols.

解決方法 Solution

Cmakeが作成した次のファイルを編集することで解決する。
  It solves by editing the next file created by Cmake.

SRC\CMakeFiles\lapack.dir\link.txt

次の一文をx86_64-w64-mingw32-gfortran.exe のオプションとして加える。
  Add the following sentence as an option of x86_64-w64-mingw32-gfortran.exe

-Wl,--allow-multiple-definition

link.txtの該当行は次のようになる。
  The corresponding line of link.txt is edited as follows.

SRC\CMakeFiles\lapack.dir\link.txt
... 
C:\MinGW\bin\x86_64-w64-mingw32-gfortran.exe  -O2 -DNDEBUG -O2  -shared -o ..\bin\liblapack.dll -Wl,--allow-multiple-definition -Wl,--out-implib,..\lib\liblapack.dll.a -Wl,--major-image-version,3,--minor-image-version,8 -Wl,--whole-archive CMakeFiles\lapack.dir/objects.a -Wl,--no-whole-archive @CMakeFiles\lapack.dir\linklibs.rsp -Wl,--output-def,lapack.def
... 

これでC:/MinGW/bin/mingw32-make.exeを実行すればlapack.dllが作成されるはず。
  Now if you run C: /MinGW/bin/mingw32-make.exe, lapack.dll should be created.

がんばろう。
  Good Luck.

kimurap
Qiita初心者ですが、よろしくお願いします。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした