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

LNK2019 error using Fortran 12 and VS2010 pro

skayres
Beginner
1,061 Views

I have a mixed code C++ and Fortran project that compiles under VS2008 and Fortran 11. I am now trying to compile with VS2010 and Fortran 12 (Fortran Composer XE 2011). Using the release notes instructions, I was able to resolve a few MSB4075 errors. However those same subprojects that gave the MSB4075 errors now give a LNK2019 error when building. Here is the build output:

3>------ Rebuild All started: Project: lint (tools_gpl\\lint\\lint), Configuration: Debug Win32 ------

3>Build started 7/18/2011 3:12:42 PM.

3>_PrepareForClean:

3> Deleting file "Debug\\lint.lastbuildstate".

3>InitializeBuildStatus:

3> Touching "Debug\\lint.unsuccessfulbuild".

3>ClCompile:

3> main.cpp

3>main.obj : error LNK2019: unresolved external symbol _MAIN_LINT referenced in function _main

3>..\\..\\bin\\Debug\\lint.exe : fatal error LNK1120: 1 unresolved externals

3>

3>Build FAILED.

I have attached an example c++ wrapper and Fortran subroutine that is causing the error. Can you see anything that needs to be changed for a VS2010 build?

Thanks,
Steve



0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,061 Views
Did you add the library from the Fortran project to the C project? As it also says in the release notes, VC2010 won't link in the library from a non-C dependent project.
0 Kudos
bmchenry
New Contributor II
1,061 Views
do you meanproject? or solution?
why don't you create a solution with both the c project and the fortran project in it. and then set the project dependancy and start-up project (right click in solution explorer and let it know ifc project depend on the Fortran project orvisa versa? and then let it know compile order?)
and one last item,make the output dirrectories for each project
$(SolutionDir)$(ConfigurationName)
0 Kudos
Steven_L_Intel1
Employee
1,061 Views
As I mentioned above, VC2010 will not link in libraries from a dependent non-C project. This is explained in the Fortran release notes.
0 Kudos
skayres
Beginner
1,061 Views
Yes, the library linkage was the issue. I was able to get a successful build by putting the path to the Fortran library in theAdditional Dependencies box.

Thanks for the help.
0 Kudos
bmchenry
New Contributor II
1,061 Views
yikes! curses...i moved to vs2010 about a month or so ago so will have to see if it messes up my c projects calling fortran...(it works fine on my fortran dll projects)
and of course the change from VS2008 to VS2010 losing the linking in of libraries would beg the question...
why?
guess i need to shift gears and test if it affects my projects before a fire erupts and i need to figure it out yesterday...

thanks for the heads up!
oh and thanks for the solution of putting the path in the Additional Dependencies box (think i may already do that...)
0 Kudos
Steven_L_Intel1
Employee
1,061 Views
The "why" may be that Microsoft changed the build system in VS2010 to be based on msbuild and they don't use project dependencies anymore.

A Public Service Notice - the Release Notes are there for a reason. Yes, they're long, but you should read them when you get a new release from us. (For updates it's sufficient to look at the Change History.) This is how we alert you to things you need to know.
0 Kudos
Reply