arpack-ng icon indicating copy to clipboard operation
arpack-ng copied to clipboard

Visual Studio error LNK1120

Open GillianGrayson opened this issue 5 years ago • 17 comments

Hi!

I tried to compile it using Microsoft Visual Studio Community 2017 (Version 15.9.17) with Intel Visual Fortran Compiler 19.0.0.117 but I got a link error:

arpack-ng_exports.def : error LNK2001: unresolved external symbol dlaqrb_ x64\Release MKL\arpack-ng.lib : fatal error LNK1120: 1 unresolved externals

File dlaqrb.f missing?

Please help to fix this error

Thank you!

GillianGrayson avatar Nov 16 '19 16:11 GillianGrayson

I don't have a windows to reproduce this. Someone will have to help!

sylvestre avatar Nov 16 '19 18:11 sylvestre

Would say you need lapack 3 (dlahqr used instead of deprecated dlaqrb) and this fix:

$ git diff
diff --git a/VISUAL_STUDIO/arpack-ng_exports.def b/VISUAL_STUDIO/arpack-ng_exports.def
index 2129b28..ab447a5 100644
--- a/VISUAL_STUDIO/arpack-ng_exports.def
+++ b/VISUAL_STUDIO/arpack-ng_exports.def
@@ -5,7 +5,6 @@ EXPORTS
        cmout_
        cvout_
        dgetv0_
-       dlaqrb_
        dmout_
        dnaitr_
        dnapps_

fghoussen avatar Nov 17 '19 11:11 fghoussen

Thank you! After I deleted dlaqrb_ from VISUAL_STUDIO/arpack-ng_exports.def it builds successfully.

Sorry for the next newbie questions. How can I use arpack correctly in Visual Studio projects? For example if I do the following:

  1. add path to arpack-ng.lib to Linker → General → Additional Import Library
  2. add arpack-ng.lib Linker → Input → Additional Dependencies
  3. copy arpack-ng.dll to local directory with .exe file After these steps my program compiles. But after I running it i get an run-time error: blasplus.dll was not found.

I need this blasplus.dll? I can not use arpack as stand-alone library?

Thanks a lot for your help!

GillianGrayson avatar Nov 17 '19 14:11 GillianGrayson

Please PR the fix. Arpack needs blas / lapack : you'll need to add them in your paths according to your IDE (no windows, can't help). Not sure to understand what VISUAL_STUDIO/blasplus_imports.def deals with and how to use it : you may try to remove or empty it (if removing breaks) just for testing.

fghoussen avatar Nov 17 '19 14:11 fghoussen

I tried to remove VISUAL_STUDIO/blasplus_imports.def or make it empty - many linking errors occurs.

I do not fully understand where to get .dll files from missing libraries (blasplus.dll, lapack.dll). Solution in VISUAL_STUDIO directory does not create .dll files.

GillianGrayson avatar Nov 17 '19 15:11 GillianGrayson

Give a try to cmake (or autotools) on windows ? You'll need to build blas and lapack with cmake, then, to build arpack (which needs blas / lapack) with cmake : did you try ?

As far as I remember sln / proj files are used by MS Visual Studio to gather many information including symbols exported by dll. Not used windows for years, but, I would say sln / proj "want" blasplus_imports.def, and blasplus_imports.def "wants" to find symbols in "blasplus.dll" that you'll have to provide. You may try for testing :

  • get rid of blasplus in all sln / proj files (so then you likely may remove blasplus_imports.def)
  • you will still have to provide a compiled library for blas / lapack which will seem to be compelled to be named "blas.dll" and "lapack.dll" : you'll need to compile that ones from source, MS VS is not gonna do that for you ! (likely you can't use MKL for instance as shipped blas / lapack dll are not named like that)

Cmake would probably be more flexible... Never tested on wiindows. Seems blas (embedded in lapack) and lapack for windows are available here : http://icl.cs.utk.edu/lapack-for-windows/lapack/

 >> git grep blasplus_imports.def
VISUAL_STUDIO/arpack-ng.vfproj:                         <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:&quot;$(InputDir)blasplus_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)blasplus.lib&quot; 1&gt;NUL 2&gt;NUL&#xA;lib /DEF:&quot;$(InputDir)lapack_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)lapack.lib&quot; 1&gt;NUL 2&gt;NUL" Description="Build blasplus.lib lapack.lib (imports)"/>
VISUAL_STUDIO/arpack-ng.vfproj:                         <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:&quot;$(InputDir)blasplus_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)blasplus.lib&quot; 1&gt;NUL 2&gt;NUL&#xA;lib /DEF:&quot;$(InputDir)lapack_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)lapack.lib&quot; 1&gt;NUL 2&gt;NUL" Description="Build blasplus.lib lapack.lib (imports)"/>
VISUAL_STUDIO/arpack-ng.vfproj:                         <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:&quot;$(InputDir)blasplus_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)blasplus.lib&quot; 1&gt;NUL 2&gt;NUL&#xA;lib /DEF:&quot;$(InputDir)lapack_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)lapack.lib&quot; 1&gt;NUL 2&gt;NUL" Description="Build blasplus.lib lapack.lib (imports)"/>
VISUAL_STUDIO/arpack-ng.vfproj:                         <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:&quot;$(InputDir)blasplus_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)blasplus.lib&quot; 1&gt;NUL 2&gt;NUL&#xA;lib /DEF:&quot;$(InputDir)lapack_imports.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)lapack.lib&quot; 1&gt;NUL 2&gt;NUL" Description="Build blasplus.lib lapack.lib (imports)"/>
VISUAL_STUDIO/arpack-ng.vfproj:         <File RelativePath=".\blasplus_imports.def"/>

fghoussen avatar Nov 17 '19 19:11 fghoussen

@sylvestre : https://docs.travis-ci.com/user/reference/windows/

fghoussen avatar Nov 20 '19 17:11 fghoussen

@fghoussen I don't have time or the interest to do it :)

sylvestre avatar Nov 21 '19 08:11 sylvestre

Even if you would, you'll need to wget and build blas / lapack (I guess you don't want that)

fghoussen avatar Nov 21 '19 09:11 fghoussen

You are selling me some dreams here ;)

sylvestre avatar Nov 21 '19 09:11 sylvestre

The no-always-stable-wget may turn dreams into nightmares...

fghoussen avatar Nov 21 '19 09:11 fghoussen

@GillianGrayson : works OK on W10 + cmake + MinGW + no-mpi (can't test in VS : no F90 compiler)

fghoussen avatar Nov 23 '19 20:11 fghoussen

@sylvestre : BTW, I can try to PR a windows job but need 1) git clone lapack [fetching from web - may be not always so stable ?] 2) building lapack [may be quite long]. You decide. Not a big job at my side.

fghoussen avatar Dec 01 '19 10:12 fghoussen

sure, many thanks :)

sylvestre avatar Dec 01 '19 11:12 sylvestre

Now vcpkg (one can install in visual studio) integrates arpack-ng, should we drop visual studio support? Suppress VISUAL STUDIO directory hosted in the repo? @FabienPean: what do you think?

fghoussen avatar Aug 12 '23 11:08 fghoussen

I was not even aware the folder is present :) The files seem old and don't even open correctly with VS2022. Anyway, it would be better to remove them and push people to generate build files with CMake (which is also well supported in Visual Studio itself).

FabienPean avatar Aug 13 '23 17:08 FabienPean

100% agree! :) @sylvestre: what do you think?

fghoussen avatar Aug 13 '23 17:08 fghoussen