- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am a new one turning to Intel Fortran. I use Visual studio 2008 with IVF 11. I create a fortran project and add one and only one F90 code to the project. Everything is ok. However, when I try to more fortran F90 files to the project, I get the erroe message,
1>rpca2.obj : error LNK2005: _MAIN__ already defined in fortranTest2.obj
1>Debug\Console1.exe : fatal error LNK1169: one or more multiply defined symbols found
So it seems there can be one and only one f90 file in the project. Could somebody help me with this? Thanks very much.
I am a new one turning to Intel Fortran. I use Visual studio 2008 with IVF 11. I create a fortran project and add one and only one F90 code to the project. Everything is ok. However, when I try to more fortran F90 files to the project, I get the erroe message,
1>rpca2.obj : error LNK2005: _MAIN__ already defined in fortranTest2.obj
1>Debug\Console1.exe : fatal error LNK1169: one or more multiply defined symbols found
So it seems there can be one and only one f90 file in the project. Could somebody help me with this? Thanks very much.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - yingwu
1>rpca2.obj : error LNK2005: _MAIN__ already defined in fortranTest2.obj
1>DebugConsole1.exe : fatal error LNK1169: one or more multiply defined symbols found
So it seems there can be one and only one f90 file in the project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
Make that only one Fortran main program in a normal project. Errors are conceivable which could produce an unintended main program.
Hi, thanks for your so soon reply. Because I just switch to Fortran, so my questions may be silly. Could you give me more detail in how to Make that only one Fortran main program? You mean set one file as the main program? So what about other f90 files? Is there any example? Thanks very much for your help...
PS: the solution explorer is like this:
There are two F90 files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It does not matter how many source files you have. Each source file can have one or more "program units" in it, which can be a main program, subroutine, function, BLOCK DATA or module. However, in your entire application, there can be only one main program - a program unit beginning with PROGRAM or not beginning with SUBROUTINE, FUNCTION, MODULE or BLOCK DATA.
It looks as if both source files FortranTest2.f90 and rpca2.f90 both have main programs. If what you want is to have separate executables for these programs, each one has to be in its own project. You can have more than one project in a solution. Note that only one project in a solution is the "Startup project" - this is indicated by the project name in bold face text and is the one that will be used when you ask to run or debug the solution. You can change which project is the startup project by right clicking on the new one and selecting "Set as startup project".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
It does not matter how many source files you have. Each source file can have one or more "program units" in it, which can be a main program, subroutine, function, BLOCK DATA or module. However, in your entire application, there can be only one main program - a program unit beginning with PROGRAM or not beginning with SUBROUTINE, FUNCTION, MODULE or BLOCK DATA.
It looks as if both source files FortranTest2.f90 and rpca2.f90 both have main programs. If what you want is to have separate executables for these programs, each one has to be in its own project. You can have more than one project in a solution. Note that only one project in a solution is the "Startup project" - this is indicated by the project name in bold face text and is the one that will be used when you ask to run or debug the solution. You can change which project is the startup project by right clicking on the new one and selecting "Set as startup project".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to use projects, that's the way you have to do it. Only one main program per project. You don't have to have all the projects in a single solution - typically you would do that only if the projects were closely related. More common is to have a separate solution for each executable.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page