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

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

Jump to solution

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

Accepted Solutions
Highlighted
Black Belt
364 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

0 Kudos
6 Replies
Highlighted
Black Belt
365 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

0 Kudos
Highlighted
Beginner
364 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

0 Kudos
Highlighted
Black Belt
364 Views

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

0 Kudos
Highlighted
Beginner
364 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 !

0 Kudos
Highlighted
Black Belt Retired Employee
364 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.

0 Kudos
Highlighted
Beginner
364 Views

@Dr. Fortran

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

0 Kudos