Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

error LNK2019

shengyen_l_
Beginner
964 Views

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:

#include

<stdio.h>

#ifdef _cplusplus

extern "C" {

#endif

void _stdcall THERDF(int *parent);

#ifdef _cplusplus

}

#endif

void main(void)

{

  int parent=10;

  THERDF(&parent);

}

subroutine THERDF(parent)

implicit none

integer:: parent

print*, parent

return

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.

Best,

SY Li

 

0 Kudos
3 Replies
Judith_W_Intel
Employee
964 Views
I think you need two underscores in the macro, i.e. _cpluplus should be __cplusplus It looks like the symbol is still mangled... Judy
0 Kudos
shengyen_l_
Beginner
964 Views
Thank you so much, I figured it out finally...
0 Kudos
shengyen_l_
Beginner
964 Views
Thank you so much, I figured it out finally...
0 Kudos
Reply