我想编译链接到acml的程序。在cygwin(win64)中,gfortran链接到acml:
$ gfortran empty.f90 -L/c:/cygwin64/acml5.3.1/win64/lib/libacml_dll.lib
产量
/tmp/ccKechZN.o:empty.f90:(.text+0xff): undefined reference to `drandinitialize_'
/tmp/ccKechZN.o:empty.f90:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `drandinitialize_'
/tmp/ccKechZN.o:empty.f90:(.text+0x13b): undefined reference to `drandgaussian_'
/tmp/ccKechZN.o:empty.f90:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `drandgaussian_'
collect2: error: ld returned 1 exit status
我在documentation的帮助下尝试了一些其他的东西,但没有任何东西成功地允许编译器与acml链接。我还尝试通过添加-l acml_dll
链接到库并收到以下错误:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lacml_dll
collect2: error: ld returned 1 exit status
我已经验证.lib存在于指定的目录中。也许是一个相关的问题,我也试图在win64上执行ifort链接到acml的输出。我正在使用" Intel 64 Visual Studio 2013模式"命令提示符编译一个从acml调用子例程的示例程序(请参阅documentation以获取win64中的链接):
ifort /libs:dll empty.f90 c:/AMD/acml5.3.1/ifort64_int64/lib/libacml__dll.lib
产生
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.5.239 Build 20150212
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
-out:empty.exe
-subsystem:console
empty.obj
至少使用ifort程序成功编译。然后,当我执行empty.exe时,我收到以下错误:
程序无法启动,因为您的计算机缺少libacml_dll.dll。尝试重新安装该程序以解决此问题。
我尝试重新安装acml 5.3.1以及尝试acml 6.1.0,但在执行时遇到了同样的错误。
答案 0 :(得分:0)
仅仅指定库路径是不够的。您还必须告诉编译器链接库。只需将package.json
添加到编译选项即可。
此外,使用-l acml_dll
指定库路径需要路径,而不是文件。所以完整的命令看起来应该是
-L
运行程序时,还需要在运行时找到库。实现此目的的最简单方法是使用rpath
:
gfortran empty.f90 -L/c:/cygwin64/acml5.3.1/win64/lib/ -lacml_dll