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

To add a lib dependency globally instead of "additional dependencies" in Visual Studio

Jihoe_K_
Beginner
1,346 Views

   I want to use an MPI lib file impid.lib for every visual fortran project I am gonna make later.

   I know that I can add the dependency in Project Properties - Linker - Input - Additional Dependencies.

   But is there anyway to add this dependency globally, not project-based ?

0 Kudos
15 Replies
dboggs
New Contributor I
1,346 Views

In Visual Studio, try either this:

Tools > Options > Intel Visual Fortran > Compilers > Libraries, add the lib name to the existing list

or,

Tools > Options > Intel Visual Fortran > Compilers > Includes, Add the lib directory to the existing list

I'm not completely sure I have the last step correct in these suggestions. My own testing has been a little inconclusive. But I think one of them should work. Hopefully someone else can confirm, but you should be able to with a little trial and error.

0 Kudos
IanH
Honored Contributor II
1,346 Views

dboggs wrote:

Tools > Options > Intel Visual Fortran > Compilers > Libraries, add the lib name to the existing list

I think that might be a list of directories to search for libraries, rather than libraries to include (but I don't know for sure).

You could create and populate the LINK environment variable with the name of the library.  Bit of a sledgehammer though.

0 Kudos
SergeyKostrov
Valued Contributor II
1,346 Views
>>...But is there anyway to add this dependency globally, not project-based ? It is not possible without some tricks ( similar to what Ian described ). In overall, we always have some finite number of projects / configurations in VS solutions and that task needs to be done just once. So, you could spend more time on "inventing" some super-solution when actually that library could be added in a matter of minutes to all VS projects.
0 Kudos
DavidWhite
Valued Contributor II
1,346 Views

Just be aware that adding the libraries as suggested by dboggs will be undone by the VS integration when you update the Fortran compiler.

So you need to save any changes you make to the libraries and includes folders elsewhere so that you can recover the settings after updating.

Regards,

David

0 Kudos
Steven_L_Intel1
Employee
1,346 Views

David, in more recent versions compiler updates don't undo the changes there.

I can't think of a way to get a specific library always linked in for every program. If you have some include file or module you always use, you could add the line:

!DEC$ OBJCOMMENT LIB:"impid.lib"

to the source and it would have the effect you're looking for.

0 Kudos
dboggs
New Contributor I
1,346 Views

OK, I can see now that I gave some faulty advice earlier. I got this from this forum originally, didn't read it carefully, tried something very similar and thought it succeeded, but it does not.

It was however half right and you may find this helpful. Using Tools > Options > Intel Visual Fortran > Compilers > Libraries, you can enter the PATH to your library, but not the specific library name. You still have to enter the library NAME (impid.lib in your case) for every project. But you don't have to enter the PATH. That can be beneficial if the pathname is very long, or if you move the library location from time to time.

It is also interesting to note that, even if my original suggestion had worked, it would be limited because the library configuration (e.g. debug or release) can not be specified on a configuration-dependent basis in the Tools > Options technique. This could (would) lead to linker errors if you build both debug and release versions of your project, because each type of build requires the corresponding build type of your user library.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,346 Views

Have you considered the ramifications as to what happens when you build a library or standalone .obj instead of an executable?

This said, you could add the Path to the library in the Libraries property .AND. add as the last option the filename of the library with the .lib extension. If the path to the library is not fully resolved then fully qualify (possibly with macro) the pathToLib\YourLib.lib

IOW insert a file spec of the library into the last position of Default Options (after link)

Jim Dempsey

 

0 Kudos
DavidWhite
Valued Contributor II
1,346 Views

Steve,

You said "in more recent versions compiler updates don't undo the changes there".  This has not been my experience, unless there are two different places to add the extra folders.

Every time the VS Integration is run, I lose these changes, and have to re-enter them.

Thanks,

David

0 Kudos
Steven_L_Intel1
Employee
1,346 Views

It is not supposed to remove these on a simple update. I tend to uninstall and reinstall, and the uninstall does remove them, but I have seen them persist across an update as well. I'll look at this again.

0 Kudos
DavidWhite
Valued Contributor II
1,346 Views

Steve,

I normally do an update, but do not retain multiple copies of the compiler. Not sure if doing the update this way is different to keeping different versions in parallel.

Thanks,

David

0 Kudos
Steven_L_Intel1
Employee
1,346 Views

David, it should work. I will test it again.

0 Kudos
Ever_B_
Beginner
1,346 Views

Steve Lionel (Intel) wrote:

David, in more recent versions compiler updates don't undo the changes there.

I can't think of a way to get a specific library always linked in for every program. If you have some include file or module you always use, you could add the line:

!DEC$ OBJCOMMENT LIB:"impid.lib"

to the source and it would have the effect you're looking for.

For me It is easier and more readable to put a line in the code. Since I am using both BLAS and LAPACK, I put this:

!DEC$ OBJCOMMENT LIB:"mkl_blas95.lib"
!DEC$ OBJCOMMENT LIB:"mkl_lapack95.lib"
include 'lapack.f90'    !superseeds include 'blas.f90'

Question: Is there a !$DEC statement to substitute/avoid doing the following in VS ?

    Project> Properties> Fortran> Libraries> Use Intel Math Kernel Library> Sequential (or parallel)

 

0 Kudos
JohnNichols
Valued Contributor III
1,345 Views

Steve:

I found this example with the MKL library. Is there a simple set of instructions on how to include an MKL subroutine in a standard Fortran Program run as a console app in VS 2013 with the latest INTAL compiler. 

Regards

JMN

!*******************************************************************************
!  Content:
!      Example shows how to migrate from NETLIB LAPACK95 to
!      Intel(R) Math Kernel Library (MKL) LAPACK95
!*******************************************************************************
      PROGRAM SGBSV_MAIN

!  -- LAPACK95 EXAMPLE DRIVER ROUTINE (VERSION 1.0) --
!     UNI-C, DENMARK
!     DECEMBER, 1999

!  .. "Use Statements"
      USE MKL95_PRECISION, ONLY: WP => SP
      USE MKL95_LAPACK, ONLY: GBSV
!  .. "Implicit Statement" ..
      IMPLICIT NONE
!  .. "Local Scalars" ..
      INTEGER :: K, KL, KU, I, J, N, NRHS, INFO
!  .. "Local Arrays" ..
      INTEGER, ALLOCATABLE :: IPIV(:)
      REAL(WP), ALLOCATABLE :: AB(:,:), B(:,:)
!  .. "Executable Statements" ..
       WRITE (*,*) 'SGBSV Example Program Results.'
       N = 6; KL = 2; KU = 1; NRHS = 2
       ALLOCATE ( AB(2*KL+KU+1,N), B(N,NRHS), IPIV(N))
       AB=0.0; B=0.0; IPIV=0

       DO I=KL+1,2*KL+KU+1
       DO J=1,N
          READ(*,'(F3.0)') AB(I,J)
       ENDDO
       ENDDO

       WRITE(*,*) 'The matrix AB:'
       DO I=1,N; WRITE(*,"(5(I3,1X,1X),I3,1X)") INT(AB(I,:));
       ENDDO

       DO I = 1, NRHS
       DO J = 1, N
       DO K = MAX(1,J-KL),MIN(J+KU,N); B(J,I) = AB(KL+KU+1+J-K,K)+B(J,I);
       ENDDO
       ENDDO;
       B(:,I) = B(:,I)*I;
       ENDDO

       WRITE(*,*) 'The RHS matrix B:'
       DO I=1,N; WRITE(*,"(1(I3,1X),I3,1X)") INT(B(I,:)); ENDDO
       WRITE(*,*) 'CALL GBSV( AB, B, 2, IPIV, INFO)'

       CALL GBSV( AB, B, 2, IPIV, INFO )

       WRITE(*,*)'AB on exit: '
       DO I=1,2*KL+KU+1; WRITE(*,"(5(E13.6,1X),E13.6,1X)") AB(I,:); ENDDO
       WRITE(*,*)'B on exit: '
       DO I=1,N; WRITE(*,"(1(E13.6,1X),E13.6,1X)") B(I,:); ENDDO
       WRITE(*,*)'IPIV on exit: ', IPIV
       WRITE(*,*)'INFO on exit: ', INFO

       END PROGRAM SGBSV_MAIN

 

0 Kudos
JohnNichols
Valued Contributor III
1,345 Views

Error 1  error LNK2019: unresolved external symbol _SGBSV_MKL95 referenced in function _MAIN__ gbsv.obj 
 

Steve:

When I create a Intel Fortran blank console program, add in the previous code, turn on the swtich to use MKL compilers and I have run the MKLVARS as IA32 I get this error in VS 2013 on compile.

0 Kudos
Steven_L_Intel1
Employee
1,345 Views

Ever B - You can use the MKL Link Line Advisor to get the set of libraries you need for a particular configuration of MKL and then name those in OBJCOMMENT directives. This will do the equivalent of the project option.

John - add the line:

!DEC$ OBJCOMMENT LIB:"mkl_lapack95.lib"

to your source (just after the PROGRAM statement is fine.) The LAPACK routines are not linked in by default.

0 Kudos
Reply