Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28501 Discussions

NAG Library with Intel Fortran + Visual Studio

Dix_Carneiro__Rafael
1,246 Views

Hello, I am trying to use the NAG library with Intel Fortran using Visual Studio. Here is what I have done in Visual Studio:

In Visual Studio, Menu Tools -> Options -> Intel Compilers and Libraries -> Visual Fortran -> Compilers

add to Libraries:

C:\Program Files\NAG\NL29\nlw6i29del\lib

add to Include:

C:\Program Files\NAG\NL29\nlw6i29del\include

I am getting an error message as follows:

error #7002: Error in opening the compiled module file. Check INCLUDE paths. [NAG_LIBRARY]

Any hints of what I am doing wrong?

Many thanks!

0 Kudos
8 Replies
Steve_Lionel
Honored Contributor III
1,226 Views

Does a file called NAG_LIBRARY.mod (case doesn't matter) exist in C:\Program Files\NAG\NL29\nlw6i29del\include ? Does the NAG Library documentation perhaps tell you to compile a NAG_LIBRARY.f90 into a .mod file?

0 Kudos
Dix_Carneiro__Rafael
1,213 Views

Many thanks, Steve.

I did find a NAG_LIBRARY.mod file in another folder and am now directing to it in "Additional Include Directories". It's now compiling.

0 Kudos
mecej4
Honored Contributor III
1,216 Views

There is a file called envvars.bat in the batch directory of the NAG library installation that sets up the correct environment. If that environment is not set up before you run Visual Studio, the necessary module files will not be found.

Note that the include directory contains C include files. The Fortran mod files are in the subdirectory nag_interface_blocks, and that directory must be accessible through %INCLUDE% or by specifying the appropriate /I or /module: options.

0 Kudos
Dix_Carneiro__Rafael
1,212 Views

Thank you, I did add the nag_interface_blocks path to "Additional Include Directories". It's now working. 

0 Kudos
Dix_Carneiro__Rafael
1,169 Views

Hi again. I was able to compile my program using the USE line below:

Use nag_library, Only: e01daf, e02dff, nag_wp, x04cbf

However, once I effectively call subroutine e01daf, I receive two errors:

error LNK2019: unresolved external symbol e01daf
error LNK1120: unresolved externals

I suspect I should be pointing the compiler to yet another directory, but I am unsure which one.

I added these two directories under "Additional Library Dependencies":

C:\Program Files\NAG\NL29\nlw6i29del\lib
C:\Program Files\NAG\NL29\nlw6i29del\bin

Many thanks for any help.

0 Kudos
mecej4
Honored Contributor III
1,148 Views

Messages with "...unresolved external symbol..." are from the linker, not the compiler. You have to choose which NAG library you wish to use (dynamic/static, NAG/MKL, etc., please read the NAG users note for details), and specify this library in your project settings. If you add only the NAG library directory in your project settings, that is not enough -- it tells VS where to find libraries, but not which libraries to use.

0 Kudos
Dix_Carneiro__Rafael
1,124 Views

Thank you very much for these comments.

I was able to find the relevant documentation here: https://www.nag.com/doc/inun/nl29/w6idel/un.html -- they have detailed instructions for linking the NAG library with Visual Studio, which I followed multiple times. Still, I am getting the error messages attached (as a screenshot). Any hints?

Very grateful!

Dix_Carneiro__Rafael_0-1680885622657.png

 

0 Kudos
Dix_Carneiro__Rafael
1,114 Views

Hi, I used another library (NLW6I29DE_mkl.lib) and it worked. I believe I had to add other dependencies for the one I selected below.

In any case, many thanks for the help so far!

0 Kudos
Reply