I'd like to use ACML to speed up my code which uses Armadillo.
Without ACML, everything works fine, both on Linux (ArchLinux x86_64, gcc 4.8.1) and Windows (64 bits, Visual Studio 2012 Update 3). I develop inside Qt Creator and generate a makefile using qmake. Armadillo is directly included in my project and as such does not require special treatment for compilation or linking (as it is simply a template library).
I want now to use ACML. I downloaded ACML 5.3.1 on both linux (which I compiled part using gfortran) and acml5.3.1-ifort64.exe for Windows. An important question here: do I need a fortran compiler on Windows for ACML if all I'm doing is developing in C/C++?
I then try to enable ACML inside Armadillo (in config.hpp, Armadillo's configuration header) and add the required link flags for ACML. On Linux, no problem, it links fine (as reported by 'ldd'):
$ ldd project
libacml_mp.so => /usr/lib/acml/gfortran/libacml_mp.so (0x00007f420e588000)
On Windows though, I cannot link correctly. I don't mind linking either statically or dynamically. This project will might be shipped in a proprietary application, so I would like to be as close as possible to the Redistribution Agreements.The later specifies that I cannot distribute, publish or sublicense the Documentation, the Sample Source, the Libraries (except when built into the Distributed Software). So is it required to link statically then?
In any case, linking to a library is done through qmake's LIBS variable:
INCLUDEPATH += /usr/include/acml/gfortran/
LIBS += -L/usr/lib/acml/gfortran/ -lacml_mp
ACMLDIR = $$quote(C:\AMD\acml5.3.1\ifort64_mp)
INCLUDEPATH += $$quote($$ACMLDIR\include)
#LIBS += -L$$quote($$ACMLDIR\lib) -lacml_mp
LIBS += $$quote(C:\AMD\acml5.3.1\ifort64_mp\lib\libacml_mp_dll.lib)
But it always fails to link:
tf.obj:-1: error: LNK2019: unresolved external symbol sgetrf_ referenced in function "void __cdecl arma::lapack::getrf<double>(int *,int *,double *,int *,int *,int *)" (??$getrf@N@lapack@arma@@YAXPEAH0PEAN000@Z)
Grepping for "sgetrf_" reveals that libacml_mp.lib contains that symbol but even adding "$$quote(C:\AMD\acml5.3.1\ifort64_mp\lib\libacml_mp.lib)" to the LIBS variable gives the same LNK2019 error.
The unresolved symbol is a lapack function (or function wrapper?) so if I understand correctly, the linker is not finding the right symbol in ACML library. Normally I would check that the linking flags are ok, but they seem to be!
All in all, my questions are:
1) Do I need a fortran compiler on Windows for ACML if all I'm doing is developing in C/C++?
2) Should I link statically or dynamically?
3) How to link correctly?
Thanks a lot for any hints!!