Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
4 Views

Get path variable inside Visual Studio

I have a Fortran solution which compiles and builds with no issues. It generates an executable for my configuration of choice. I can run the application using Microsoft Visual Studio and it runs successfully.

The issue is when I try to run it outside of the Visual Studio environment, i.e by copying the executable and running from Windows command prompt. In this case I get the following error message:

The program can't start because mkl_intel_thread.dll is missing from your computer. Try reinstalling the program to fix this problem.

Upon moving the required dll into my working directory and rerunning I get another missing dll error:

The program can't start because mkl_core.dll is missing from your computer. Try reinstalling the program to fix this problem.

Upon again moving mkl_core.dll to the working directory I get another error:

The application was unable to start correctly (0xc000007b). Click OK to close the application.

I have no idea why this is happening. I know that recently some items have been moved from the application to dll form. Our software engineer had me install some redistributables (https://software.intel.com/en-us/articles/redistributables-for-intel-parallel-studio-xe-2016-compose...). This didn't help. However what I have understood is that my path environment variable in the command prompt is missing some important paths which contain the necessary libraries. 

I'd like to get the contents of the Visual Studio 2015 path environment variable such that I can compare with the path variable from my command prompt. I think this might help solve the problem.

How can I get the path environment variable for a Visual Studio 2015 session running intel fortran?

0 Kudos
4 Replies
Highlighted
Beginner
4 Views

 

 

Hi

You can use the kernel32 function GetEnvironmentVariable to access the PATH as it is seen from your fortran program

BR/Leonard

program main
    use kernel32
    integer,parameter:: nch=2000
    character(len=nch):: string
    integer::size,iret
    
    size=nch
    
    iret=GetEnvironmentVariable('PATH'c,string,size)
    
    if(iret.eq.0) then
        write(*,*) 'no success'
    elseif(iret.gt.nch-1)then
        write(*,*) 'please increase string size to nch > ',iret
    else
        write(*,*) 'PATH is'
        write(*,*) string(1:iret)
    endif

end

 

0 Kudos
Highlighted
Valued Contributor II
4 Views

It is easier to use the

It is easier to use the standard Fortran subroutine get_environment_variable:

CALL GET_ENVIRONMENT_VARIABLE (name [,value,length,status,trim_name])

(copied from the Intel documentation)

The message "The application was unable to start correctly (0xc000007b). Click OK to close the application." may be due to the program accessing the wrong version of some library.

0 Kudos
Highlighted
Black Belt
4 Views

Quote:awa5114 wrote:The issue

awa5114 wrote:
The issue is when I try to run it outside of the Visual Studio environment, i.e by copying the executable and running from Windows command prompt.

This will not work most of the time, because the default command window will not have PATH set up to make the Intel runtime DLLs accessible. These DLLs are in the <intel installation folder>...\windows\redist\<arch>\.. folders. Either write a batch file to adjust PATH accordingly and run it first, or use one of the special command windows configured for use with the Intel compilers (under Start - Intel Parallel Studio).

0 Kudos
Highlighted
Black Belt
4 Views

The fundamental problem here

The fundamental problem here is that the Intel “performance libraries” aren’t added to PATH when the product is installed. Instead you must do this manually. If you are in Visual Studio or a compiler build command line environment, PATH is augmented to add these, but otherwise you’re on your own.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos