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

How to create stand-alone exe file?

szilagyi__jozsef
Beginner
1,700 Views

Dear Users: With my old Digital Fortran (DF) I could run any '.exe' file directly from a command line or from MATLAB. How can I do the same with Parallel Studio XE? I do not want to do anything fancy, just reading in and writing out ascii files. My old DF exe still runs on Win10, but not the newly created exe performing the same under Visual Studio but not alone. In the latter case I get a message: 'mkl_intel_thread.dll cannot be found'. I also noticed that the new exe is much smaller than the old (DF) exe that actually still runs separately. Any help would be greatly appreciated, Joe.

 

 

0 Kudos
14 Replies
mecej4
Honored Contributor III
1,700 Views

With DF, you probably used static libraries, and the EXE produced contained the code for all the library routines needed, and was self-contained. You could run it in any command window and it would work.

If your code uses MKL routines, and depending on the default options used, an EXE produced by Intel Fortran will depend on a number of runtime DLLs such as the one that you listed. You must use an Ifort command window, or add the directory (or directories) containing the DLLs to PATH before running the EXE in a plain old command window.

If you are using a current version of the Intel compiler, you will find the MKL DLLs in <installation directory>\redist\ia32\mkl or <installation directory>\redist\intel64\mkl, and should add the full path of your chosen version of the MKL redistributables to PATH.

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4: Could you tell me the steps the same way I was able to add the path to the IMSL library explained in its readme file? Specifically, my problem is if I can directly tell the path or should I use some general language like this: $(FNL_DIR)\IA32\LIB employed for the IMSL library. My eventual goal would be to give the executable file for a colleague to use for a project we are working on, so somehow the necessary library files should be included in the final exe file that I create and share. Many thank again, Joe.

 

0 Kudos
mecej4
Honored Contributor III
1,700 Views

The Ifort package is about ten times larger than the DF package, and is much more complex, because a number of new capabilities have been added. My suggestion is that you ask your colleague/client to install the Intel Redistributables that match your compiler, see https://software.intel.com/en-us/articles/redistributables-for-intel-parallel-studio-xe-2017-composer-edition-for-windows, and that you use DLL libraries as far as possible.

Installation of the redistributables on your colleague will modify the system PATH such that he/she can simply run the EXE that you transfer, without having to worry about modifying PATH, etc.

On the other hand, if you wish to mimic FNLSETUP.BAT, you can do something along the following lines (all paths must be changed to suit, naturally):

@set inteld=c:\Intel16\compilers_and_libraries\windows\
@path %inteld%\redist\ia32_win\compiler;%inteld%\redist\ia32_win\mkl;%path%
title Ifort-MKL

You can replace "ia32_win% by "intel64" if a 64-bit EXE is being used.

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4: In the meantime I added the path to the mkl similar what I found in the window PATH for the redist mpirt and lib directories but it did not make any difference. I still get the same message about the mkl_intel_thread.dll as being not found (when I directly run the exe file outside the VS environment) even though I can find that specific dll on my computer. Funny thing is that as far as I know my code does not even call the mkl, it calls IMSL though. I would be happy if I could access and run the stand-alone exe file created by Parallel Studio EX on my own computer let alone sharing it with my colleague. Any other idea beside this path setting that may work? Many thanks again, Joe.

0 Kudos
mecej4
Honored Contributor III
1,700 Views

Depending on the source of your IMSL package (from VNI/Roguewave or from Intel), IMSL may have installed its own version of the MKL DLLs. You may also have a mix of 32 and 64 bit MKL DLLs on your PC. Other packages (such as Matlab, for one) may also install their own MKL DLLs. Any recommendation that I make without knowing what is on your PC is likely to cause more trouble.

At least, now that we know that you used IMSL to build the test EXE, let me know how you built it. At the command line, inside VS, etc.? What configuration did you use? What were environment variables such as PATH and LIB set to when you built the EXE? Which version of IMSL and Intel compiler do you use? As you can imagine, the number of possible combinations too large to give an answer that will cover all of them.

Such issues are usually easy to solve, once we have been allowed to examine the patient. If you have a build-log from a VS build, that would provide a wealth of information and you could attach the file "buildlog.htm" to your reply, after putting it in a Zip file.

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4: Yes, probably I am making some very basic blunder somewhere. I am using Intel Parallel Studio 2013 XE 2013 from Roguewave who also provided me the IMSL which is found in a VNI directory though. I am generating my exe from VS using the choosable roll down commands: compile and build. Once it is done without any problem then I switch from Debug mode to Release mode and run the code without any hitch within the VS environment. However, when exiting the VS and going into the Release directory and double clicking the exe file, that is when I see the bad message. A few minutes ago I looked up the mkl installation guide and run the mvars.bat files without any effect seemingly since the same problem exists. Indeed, later I would like to run the exe from MATLAB and when I do that nothing happens, MATLAB runs over the exe program execution without any message but apparently without executing the exe file. I get the message about the missing dll only when I directly try to run the exe file. I am using a 64 bit computer but the IPS XE 2013 seems to be a 32bit version which is again fine with me. I attached the last log file. Thanks a lot for doing this,  Joe. PS: Please, let me know if you still need the PATH and LIB vars. I will somehow copy them into a file and send them to you.

 
Build Log
   
 

Build started: Project: twb_tw_calc, Configuration: Release|Win32

Output
   
Linking...
Link /OUT:"Release\twb_tw_calc.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.lib" "Release\twb_tw_calc.obj"
Link: executing 'link'

Embedding manifest...
mt.exe /nologo /outputresource:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe;#1" /manifest "D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe.intermediate.manifest"

twb_tw_calc - 0 error(s), 0 warning(s)

 

0 Kudos
mecej4
Honored Contributor III
1,700 Views

szilagyi, jozsef wrote:
However, when exiting the VS and going into the Release directory and double clicking the exe file, that is when I see the bad message.

There is the smoking gun. When you double click the EXE in a folder that you opened in Windows Explorer, the system PATH is used, and the system path does not contain MKL, as you can see in the Advanced: Environment Variables panel of the System Properties Control Panel; nor should you modify the system PATH just to address a local problem, unless you are sure of needing only one environment (and one version of MKL) on your  computer.

Instead of using the Explorer, go to the Start Menu and find the Intel Compiler or Parallel Studio command prompt. Open that command window, change to the directory containing your EXE,  and type the name of your EXE (or, from any other directory, type the full pathname of the EXE).

Alternatively, create a batch file that sets the PATH and runs the EXE, and create a shortcut for the batch file. Then, you can open the containing folder in Explorer and double click the shortcut.

Build Log

 Build started: Project: twb_tw_calc, Configuration: Release|Win32

Output

 Linking...

Link /OUT:"Release\twb_tw_calc.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.lib" "Release\twb_tw_calc.obj"
Link: executing 'link'

Embedding manifest...
mt.exe /nologo /outputresource:"D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe;#1" /manifest "D:\BME18tavasz\ToNing\twb_tw_calc\twb_tw_calc\Release\twb_tw_calc.exe.intermediate.manifest"

twb_tw_calc - 0 error(s), 0 warning(s)

Much of the content of the file was lost because you posted it in line. Please put the contents in a "code-snippet" (see {} icon in the toolbar above as you are typing), or put any files that you want to attach into a Zip or .tgz file and attach the file (see "Attach Files to Post" below, as you are typing).

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4: But that does not explain why nothing happens when MATLAB tries to Access the exe file or does it? The log file is just that, nothing is missing, I checked. Sorry but your batch file creation is beyond my general knowledge of the subject. Would it also solve the MATLAB problem? Also, should I get rid of the reference to the mkl that I inserted into the System path file? That at least I can do. Thanks a lot, Joe.

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4: I tried to run the exe file from a command line within the same directory and got the same error message. Thanks, Joe.

0 Kudos
mecej4
Honored Contributor III
1,700 Views

szilagyi, jozsef wrote:
Dear mecej4: I tried to run the exe file from a command line within the same directory and got the same error message. Thanks, Joe.

If that was a "plain old" command window, and not one configured to be used with Intel Fortran and MKL, you would get the error message. Even from such a command window, you can modify PATH by typing

   PATH = %PATH%;<insert full path to directory containing the MKL DLLs>

before running your EXE. This will work, but you would have to enter this path modification command at the beginning of every session. Putting the command into a batch file and using the batch file would let you avoid having to do that. That is why I recommended creating a batch file. Or using the batch file provided by Intel which is installed along with everything else that is included with Parallel Studio or Fortran Composer.

0 Kudos
John_Campbell
New Contributor II
1,700 Views

I have a suggestion that there is a need for an interactive user friendly utility (wizard?) that can create a path command when running a program and also suggest the compatible library paths required for building a program.

There appear to be many complications between release/debug, dynamic/static, f77/f90 library and also confirming the sufficient directories in the path/build list.

Can something which can suggest what is needed as a complete and compatible list be provided for both developers and users ?

There appear to be a lot of problems reported where this is not the case and a user friendly wizard could help many ifort users.

0 Kudos
szilagyi__jozsef
Beginner
1,700 Views

Dear mecej4 and John: Thanks for your superb help, it finally works. I inserted the full path of the mkl in the System path. John: What I am really missing is an option that the compiler could create a stand-alone exe file that contains ALL the necessary dll files the program uses. This was the case with my old DF. The exe files still work on my new PC as stand-alones without any additional path modifications for dlls. Of course, that old exe is larger than the one my new Fortran creates without the dlls, but it still a very convenient property of the old DF. Could something be achieved with the newer versions of Intel Fortran? This would be a better approach than creating a wizard to collect the necessary dll paths when sharing one's code with colleagues. Just a simple switch would be necessary in VS that includes or excludes the necessary dlls into the final exe. That is how I see it practical for the simple user like myself. Thanks again mecej4 for your patience with me, cheers,  Joe.

0 Kudos
Arjen_Markus
Honored Contributor I
1,700 Views

With this sort of problems I always use the "dependency walker" tool (http://www.dependencywalker.com/). While it is showing its age - some false warnings are inevitable, it does figure out where all the DLLs are coming from and warns about DLLs that were not found. With a bit of experience you can gather the right ones and put them together with the program in a single directory for distribution.

0 Kudos
mecej4
Honored Contributor III
1,700 Views

The Linux tool ldd can be use for the purpose of displaying DLL dependencies; it is available in Cygwin, WSL (Windows Subsystem for Linux) and as part of other tools packages.

What OP wants is, in my opinion, a bit unreasonable today. Here is a simple example to make the point. I took a 4 kB source file that calls an IMSL routine. Compiled to use dynamic libraries, it produced a 30 kB exe file that depends on 16 DLLs (some  from Windows, some from MSVC, some from Intel). The same source file, compiled to use static libraries, produced a 17 MB exe file which still depends on 6 DLLs (5 from Windows, one from Intel). 

Given the size penalty (over 500 times larger EXE) and the inability to make the EXE completely independent of DLLs, is this goal worth pursuing? As I stated in #4, anyone can download and install the MKL redistributables package free of charge.

There are some additional steps to be taken if it is expected that the client is running Windows XP or older.

At one time, Intel supported the building of custom MKL DLLs (see https://software.intel.com/en-us/mkl-windows-developer-guide-building-custom-dynamic-link-libraries ) for distribution by a developer along with the application EXE. Perhaps the market demand for this feature is now felt to be minor.

 

0 Kudos
Reply