- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page