Example C++ calling Fortran DLL

Example C++ calling Fortran DLL

Hi,

I have been trying to get the example "C_calls_Fortran" supplied with Intel Composer 2013 working, however so far I have been unsuccessful.  I successfully compiled FSUB.f90 to a dll and then created a project under Visual C++ 2010 Express where I added the C++ source file and the DLL as a resource.  When I tried to build I got the following linker error messages.

CallFortran2.obj : error LNK2028: unresolved token (0A00000F) "extern "C" void __cdecl FSUB(int *,char *,char *,unsigned int,unsigned int)" (?FSUB@@$$J0YAXPAHPAD1II@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)
1>CallFortran2.obj : error LNK2019: unresolved external symbol "extern "C" void __cdecl FSUB(int *,char *,char *,unsigned int,unsigned int)" (?FSUB@@$$J0YAXPAHPAD1II@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)
1>C:\Users\Ed\documents\visual studio 2010\Projects\CallFortran2\Debug\CallFortran2.exe : fatal error LNK1120: 2 unresolved externals

I have also tried opening the .sln file directly in  Visual; Studio 2008 Professional  in which case I get the error message "... cannot be opened because its project type is not supported by this version of Visual Studio".  If I try doing the same thing in Visual C++ 2010 Express the Visual Studio conversion wizard is activated saying that the project was saved in an earlier version of VS and needs to be converted.  The conversion process does not convert all the files  successfully so this approach did help either.

If you have any advice as to how I can get this example working that would be greatly appreciated.

Thanks

Ed

3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

When you created the DLL, a corresponding .LIB file would have been generated, containing information on the linkages to the routines in the DLL. You should add that import library to your C++/C project in order to resolve the external symbols in the Fortran DLL that need to be called from C/C++.

Thanks, that works.

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!