error LNK2019

error LNK2019

Dear all

I understand that this issue has been discussed for many many times, but I still can not pass through it... I am using parallel studio XE 2011 to build C++ as the main program calling fortran. For testing, my code is simple:



#ifdef _cplusplus

extern "C" {


void _stdcall THERDF(int *parent);

#ifdef _cplusplus



void main(void)


  int parent=10;



subroutine THERDF(parent)

implicit none

integer:: parent

print*, parent


end subroutine THERDF

I followed the step to setup two projects in one solution

" - Right click on the C++ project and select Dependencies. Check the box for the Fortran project to make it a dependent of the C++ project. - Right click on the Fortran project and select Properties > Fortran > Libraries. Set the property "Disable default library search rules to "No". - Make sure that the run-time library types match between the C++ and Fortran projects (for example, if C++ is using Multithreaded DLL, Fortran must be too

There is a one-time configuration of C++ you need to make to link in Fortran code - see the instructions at Configuring Visual Studio for Mixed-Language Applications

Now you can build the Solution and it should build and link properly.

I notice you have STDCALL routines being called. I assume those are the Fortran routines. If you're coming from Compaq Visual Fortran, you'll probably want to set the Calling Convention: CVF option in the Fortran project.

for library directiries: $(ifort_compilervv)compiler\lib\ia32;$(LibraryPath)

I got the error code

1>Liquidus.obj : error LNK2019: unresolved external symbol "void __stdcall THERDF(int *)" (?THERDF@@YGXPAH@Z) referenced in function _main

1>C:\fortran\Nomads\Liquidus\liquidus\Debug\liquidus.exe : fatal error LNK1120: 1 unresolved externals


what did I miss here? Thank you.




4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think you need two underscores in the macro, i.e. _cpluplus should be __cplusplus

It looks like the symbol is still mangled...


Thank you so much, I figured it out finally...

Thank you so much, I figured it out finally...

Leave a Comment

Please sign in to add a comment. Not a member? Join today