1

CentOS 6.4 のシステムがあり、GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) が付属しています。

私は 4 倍精度の計算を行っており、そのために devtoolset-6 を問題なくインストールしました。システムにはデフォルトのgcc/gfortranがインストールされているため、シェルをクリアしました

env -i bash

それに続いて、devtoolset-6環境を設定しました

scl enable devtoolset-6 bash 

インストールされている gcc と gfortran のバージョンを確認すると、次のようになっています。

gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
GNU Fortran (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)

ここまでは順調ですね。以下にテスト例もあります

implicit double precision(a-h,o-z)
print * , ' i:'
read(5,*) i
if(i.le.0) stop
a=i
b=sqrt(a)
print * , b
c=b*b
print * , c
end

でコンパイル

gfortran -fdefault-real-8 -o test.exe test.F

コンパイルしようとすると、次のエラーが発生します

(.text+0x20): main' /tmp/cc7n6vIv.o: In functionljacoeff_':test.F:(.text+0xf0) への未定義の参照: _gfortran_transfer_real128_write' test.F:(.text+0x16b): undefined reference to_gfortran_transfer_complex128_write' への未定義の参照' test.F:(.text+0x1ea): `_gfortran_transfer_complex128_write' への未定義の参照 collect2: エラー: ld は 1 つの終了ステータスを返しました

最初は、_gfortran_transfer_real128_write 関数が定義されていないと思っていたので、デフォルトの「nm」コマンドを使用してライブラリに devtoolset-6 が付属していることを確認しました。実際、その関数は libgfortran.a で定義されています。いくつかのデバッグとさらにデバッグを行った後、「-v」オプションを発見し、コードを再コンパイルしましたが、ld が devtoolset-6 に付属するライブラリではなく、システムの古いライブラリをチェックするように見える紛らわしいことに気付きました。LIBRARY_PATH に /usr/lib/../lib64/ フォルダーが含まれているため、エラーが発生します。いずれにしても、リンカーがこれらの関数を見つけられなかった場合は、devtoolset-6 ライブラリもチェックする必要があります。これは起こらないようです。このリンク エラーを解決するにはどうすればよいですか?

駆動: gfortran -v -fdefault-real-8 -o test.exe test.F -l gfortran -lm -shared-libgcc 組み込み仕様を使用。COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper ターゲット: x86_64-redhat-linux 構成: ../configure - -enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-6/root/usr --mandir=/opt/rh/devtoolset-6/root/usr/ share/man --infodir=/opt/rh/devtoolset-6/root/usr/share/info --with-bugurl= http://bugzilla.redhat.com/bugzilla--enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique -object --enable-linker-build-id --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=gcc4 -compatible --with-isl=/builddir/build/BUILD/gcc-6.3.1-20170216/obj-x86_64-redhat-linux/isl-install --enable-libmpx --with-mpc=/builddir/build/ BUILD/gcc-6.3.1-20170216/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux スレッド モデル: posix gcc バージョン6.3.1 20170216 (Red Hat 6.3.1-3) (GCC) COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe' '-shared-libgcc' '-mtune=generic ''-march=x86-64'/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/f951 test.F -ffixed-form -cpp=/tmp/ccjQiTpi.f90 -quiet -v テスト。 F -quiet -dumpbase test.F -mtune=generic -march=x86-64 -auxbase test -version -fdefault-real-8 -fintrinsic-modules-path /opt/rh/devtoolset-6/root/usr/lib/ gcc/x86_64-redhat-linux/6.3.1/finclude -o /tmp/cceJeO1o.s GNU Fortran (GCC) バージョン 6.3.1 20170216 (Red Hat 6.3.1-3) (x86_64-redhat-linux) GNU でコンパイルC バージョン 6.3.1 20170216 (Red Hat 6.3.1-3)、GMP バージョン 4.3.1、MPFR バージョン 2.4.1、MPC バージョン 0.8.1、isl バージョン 0.14 または 0.13 GGC ヒューリスティック: --param ggc-min-expand =100 --param ggc-min-heapsize=131072 存在しないディレクトリを無視 "/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/include-fixed" 存在しないディレクトリを無視"/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../x86_64-redhat-linux/include" #include " ..." 検索はここから始まります: #include <...> 検索はここから始まります: /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/finclude /opt/ rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/include /usr/local/include /opt/rh/devtoolset-6/root/usr/include /usr/include 終了GNU Fortran2008 (GCC) バージョン 6.3.1 20170216 (Red Hat 6.3.1-3) (x86_64-redhat-linux) GNU C バージョン 6.3.1 20170216 (Red Hat 6.3.1-3)、GMP でコンパイルバージョン 4.3.1、MPFR バージョン 2.4.1、MPC バージョン 0.8.1、isl バージョン 0.14 または 0.13 GGC ヒューリスティック: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 COLLECT_GCC_OPTIONS='-v ' '-fdefault-real-8' '-o' 'test.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/as -v - -64 -o /tmp/cc7n6vIv.o /tmp/cceJeO1o.s GNU アセンブラー バージョン 2.27 (x86_64-redhat-linux) BFD バージョン バージョン 2.27-8.el6 を使用 /opt/rh/devtoolset-6/root/ から仕様を読み取るusr/lib/gcc/x86_64-redhat-linux/6.3.1/libgfortran.spec 仕様ライブラリの名前を liborig に変更 COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe' '-shared -libgcc''-mtune=generic''-march=x86-64' COMPILER_PATH=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/opt/ rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/:/ opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/LIBRARY_PATH=/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3. 1/:/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/:/lib/.. /lib64/:/usr/lib/../lib64/: /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../.. /:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe' '-shared-libgcc' '-mtune=generic' '-march= x86-64' /opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/collect2 -plugin /opt/rh/devtoolset-6/root/usr/libexec/gcc /x86_64-redhat-linux/6.3.1/liblto_plugin.so -plugin-opt=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper - plugin-opt=-fresolution=/tmp/ccQAAlqC.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm - plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin- opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86 -64.so.2 -o test.exe /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/rh/devtoolset-6/root/usr/ lib/gcc/x86_64-redhat-linux/6.3.1/crtbegin.o -L/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1 -L/opt/ rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64 -L/lib/../lib64 -L/usr /lib/../lib64 -L/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../.. /tmp/cc7n6vIv.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/ crtend.o /usr/lib/../lib64/crtn.o /usr/lib/../lib64/crt1.o: 関数内 _start': (.text+0x20): undefined reference tomain' /tmp/cc7n6vIv.o: 関数ljacoeff_': test.F:(.text+0xf0): undefined reference to 内 _gfortran_transfer_real128_write' test.F:(.text+0x16b): _gfortran_transfer_complex128_write への未定義の参照_gfortran_transfer_complex128_write' test.F:(.text+0x1ea): undefined reference to ' collect2: エラー: ld が 1 つの終了ステータスを返しました

4

0 に答える 0