Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26734 Discussions

Run EXE in another system without any FORTRAN support, extra DLLs support & Microsoft Visual Studio

Vivek
Beginner
1,661 Views

I am using Intel Visual Fortran Compiler 15 with Visual Studio 13.

Suppose I make a simple program to add two numbers. When I use command line to compile, create object (obj), link and create exe, using the commands :-

ifort add.f90

ifort -o add add.obj 

The exe created by this method will run in any other system (running Windows) irrespective of the support of Fortran, Visual Studio, extra DLLs in it.

NOW !!!

When I use the Visual Studio to compile, build and even release than the exe created by this method which I find in some

C:\Users\VIVEK\Documents\Visual Studio 2013\Projects\Console1\Debug or 

C:\Users\VIVEK\Documents\Visual Studio 2013\Projects\Console1\Release

directory cannot run on independently run on any system (like it did in command line case). The other system reports for some error regarding DLLs. HERE I NEED HELP. I want to create the 'independent' exe from Visual Studio just like the command line did. I searched a lot in different forums and throughout the web but didn't found the exact steps that could help me. I know some dll linking or something is missing, such as dependencies. I am just a BEGINNINER in Visual Studio and it's settings. So can someone please help me with the step by step procedure. Please be detailed.

Thank You

PS:- I've also noted the difference in the size of the two exe. Eg. The exe created by the command line will be roughly near 100-120 KB (which I believe is the reason for it's independent nature). However, the exe created using the Visual Studio is somehwhat 20-30 KB.

 

0 Kudos
1 Solution
IanH
Black Belt
1,660 Views

You need to change the runtime library setting for your project within Visual Studio - the default within Visual Studio is to produce an executable that requires the Fortran runtime libraries.

Change to a Release configuration, then rIght click on your project in the solution explorer, select Properties, then in the Configuration Properties > Fortran > Libraries page change the Runtime Library option to "Multithreaded".  Rebuild your project.

(If you use OpenMP within your project, then you will still have a dependency on some of the OpenMP DLL's.)

 

View solution in original post

14 Replies
IanH
Black Belt
1,661 Views

You need to change the runtime library setting for your project within Visual Studio - the default within Visual Studio is to produce an executable that requires the Fortran runtime libraries.

Change to a Release configuration, then rIght click on your project in the solution explorer, select Properties, then in the Configuration Properties > Fortran > Libraries page change the Runtime Library option to "Multithreaded".  Rebuild your project.

(If you use OpenMP within your project, then you will still have a dependency on some of the OpenMP DLL's.)

 

View solution in original post

GGa
Beginner
969 Views

Didn't work :'-(

>> change the Runtime Library option to "Multithreaded"

My project (an EXE file to build) is set up like in the first picture attached.

On the PC used to build the EXE, it runs more or less as expected. But, on any other PC, it doesn't (see the second picture: in few words, it says "the program will not run because libifcoremd.dll was not found. Try to reinstall the program").

Where am I mistaken?

Now, the problem is that I really need to build an independent .exe file, because the users are colleagues that use the corporate's PCs, and we aren't allowed to install anything, so that the "redistributables" are not an option.

Is it possible? What options should I set?

B.t.w....  Try to copy the DLL on the target PC?

1) Unfortunately, I have perhaps about 50 "libifcoremd.dll" on my C: (DIR command gives 97 ones, but some are counted twice). They are different: not all copies of the same file.

2) I already tried to copy one (that looked somehow "reasonable" to me) on a target PC, but the program didn't run anyway.

 

Thanks in advance for any help...

IanH
Black Belt
952 Views

Did you rebuild the executable after making the change to the properties?

Attach the vfproj for the executable (and any dependent Fortran libraries) here.

There are multiple utilities that you can use to check the DLL's that an EXE load-time depends on (dumpbin /imports, the rather out of date dependency walker, newer replacements).  What do they say.

GGa
Beginner
944 Views

Hi,

 thank you for replying.

>> Did you rebuild the executable after making the change to the properties?

If I understand the question: "runtime library" has always(*) been set to "Multithreaded". Yes, I rebuilt the program after taking the screenshot (even if I knew I didn't change anything), but it was the same: the EXE runs only on "my" PC.

(*) Actually, this program used to be compiled with the old "Compaq Visual Fortran" (CVF). Unfortunately it (the CVF) does not run on Windows 10/64 bit, so I was forced to change compiler. The Intel has been chosen because it "liked" the code with relatively few changes. But now this big problem arises.

The .EXE built by the CVF was actually independent enough, with which I mean it ran on any PC we wanted. No DLLs were needed to run it (only some data files, that are available anyway), so it should be not like the code calls something that is implemented only in a DLL.

Needless to say, I can not ask to change operating system, or to have a 32 bit machine. The "Powers that be" had decided that we use Windows 10/64b.

>> Attach the vfproj for the executable (and any dependent Fortran libraries) here.

Unfortunately it's "industrial secret". If I made it public, I would be fired immediately, so getting the .EXE to work would soon become unimportant to me...

I'm really sorry to have to say "no" to someone trying to help me, but I see no alternative. I hope you will understand.

>> There are multiple utilities that you can use to check the DLL's that an EXE load-time depends on...

I'll try and check.

To be extremely honest, I expected a linker switch to exist, to build a file _without_ dependencies.

 

IanH
Black Belt
937 Views

Attach the build log from a rebuild then.  And/or show us the command line options on the "Command Line" properties page for the project.

The linker switch, closest to what you want (it is impossible to have a useful windows executable that does not have at least one dependent DLL), has apparently been set, given the dialog box screen shot you show.  Something else is going on.  But without more information, we can only guess.

GGa
Beginner
930 Views

The "Command Line" under "Fortran" is:

/nologo /Od /noaltparam /assume:byterecl /fp:strict /module:"Release\\" /object:"Release\\" /Fd"Release\vc140.pdb" /libs:static /threads /c

The "Command Line" under "Linker" is:

/OUT:"Release\(name).exe" /INCREMENTAL:NO /NOLOGO /NODEFAULTLIB:"MSVCRT" /MANIFEST:NO /SUBSYSTEM:CONSOLE,"5.01" /IMPLIB:"D:\(...path...)\sln\Release\(name).lib" vcruntime.lib

 [PAUSE because, maybe, I found something interesting...]

GGa
Beginner
916 Views

>> Attach the build log [...]

Thanks for pointing my attention on this topic.

I had forgotten... the project contains a library (a static one: .LIB). Now, the .LIB was causing the need for the missing libifcoremd.dll. I rebuilt the LIB changing the runtime option from "multithreaded DLL" to "multithreaded", but no luck: the .EXE built still resulted dependent on libifcoremd.dll (b.t.w: why?!?)

So, second trial: I just threw the LIB away, and inserted its sources directly in the program. Now I had an independent EXE as I wanted.

I can't understand the details of what happened, but I have somehow solved the immediate problem.

Thanks again for devoting some time to help me.

Steve_Lionel
Black Belt Retired Employee
908 Views

Easy way to find the culprit that is referencing the DLL library. Change the project property Linker > General > Show Progress to "Show some progress messages", then relink. The output will contain lines for the default library directives seen and tell you which object they came from. Scan for LIBIFCOREMD.LIB.

My guess is that when you rebuilt the library, either you didn't properly change the option or you were still linking to an old library.

What I often recommend, for static library builds, is to set the project property Fortran > Libraries > Disable default library search rules to Yes. This then depends on the executable project specifying the libraries to use.

GGa
Beginner
876 Views

Thank you very much, I didn't know those settings.

I also liked "show ALL progress messages" (quite long output, but helps me to understand more).

Good bye

Vivek
Beginner
1,660 Views

@IanH 

Thank you very much. That solved my problem.

Now, I got another question.

In Visual Studio, for every small program do I need to create a separate project ?

For Eg :- I make a project CALCULATE. In it I add sum.f90 file (just to add two numbers). It is compiled and runs successfully.

If in the same project CALCULATE I add another file diff.f90 (to subtract two numbers) without deleting/overwriting sum.f90, then that particular file is also successfully compiled (by right-click on diff.f90 in Solution-Explorer, select Compile option from the drop-down menu or just F7).

BUT !!! When I run the program (CTRL+F5) , it gives me error regarding some Linking

Error 1 error LNK2005: _MAIN__ already defined in sum.obj diff.obj

 

I guess that it runs the entire project, but is not able to link the two obj, because they are just small independent programs. If I delete any one of the two, the program runs successfully.

So, Is there any way in the visual-studio itself, that small independent source files/programs, such as explained above can run within a single project without the creation of any extra Project? (Without any command-line concern)

PS:- I've read in the previous forums that project must be created to run the source files(f90, f, for).

Thank You again @IanH

IanH
Black Belt
1,660 Views

No. A project builds a thing (a project has one primary output), while you are wanting it to build two (or more) things.

Vivek
Beginner
1,660 Views

@IanH

Thanks for a quick reply.

Now I am guessing that MS-VS cannot just create a simple fortran program without the necessity of essentially creating a project because then only the compile & run option will be available; or is there any such method/feature?

Thank You again !

Steve_Lionel
Black Belt Retired Employee
1,660 Views

As has been said, you need a project to build a Fortran program. If it’s just going to be a throwaway program you can do what I do and just reuse a generic console application project, overwriting or replacing the source file. There is no “compile and run” for a source file not in a project.

Vivek
Beginner
1,660 Views

@Dr. Fortran

Thanks a lot for your suggestion. Will try that out for sure.

Reply