- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a project that contains both .f90, .f (FORTRAN) and C++ files. The C++ code calls functions in the fortran files.
I have installed the Intel Visual Fortran software.
What steps do i need to do in order to get the C++ and Fortran files to both be compiled when I choose 'build'? Do i need to specify a custom build rule for the FORTRAN files?
Is there a way to compile all the fortran code as a library then point to it in the project thru the linker? I tried making a dll using the Fortran code but received an error when I tried to compile the entire project (C++ plus Fortran DLL file). I also tried creating a .lib file using a Fortran project. This didn't work either.
I have pointed to the directory that the .lib and .dll file is in and am still getting the errors below.
Currently the project type is Visual C++. Is there another project type that supports multilanguage?
Any help is appreciated.
currently these are the errors I'm receiving. All functions are Fortran Functions
------ Build started: Project: adsa1, Configuration: Debug Win32 ------
Linking...
ADSAP.obj : error LNK2019: unresolved external symbol _LMDER1@48 referenced in function _AdsaLM
ELLIP.obj : error LNK2001: unresolved external symbol _LMDER1@48
ADSAP.obj : error LNK2019: unresolved external symbol _DPOSVM@28 referenced in function _AdsaNT
ADSAP.obj : error LNK2019: unresolved external symbol _ENORM@8 referenced in function _AdsaNT
PROFILE.obj : error LNK2019: unresolved external symbol _DVERK@40 referenced in function _DropProfileData
PROFILE.obj : error LNK2019: unresolved external symbol _INTRP@36 referenced in function _DropProfileIntrp
.\Debug/adsa1.exe : fatal error LNK1120: 5 unresolved externals
Build log was saved at "file://c:\Student\Kevin\AdsaInterf 3.0 source\Debug\BuildLog.htm"
adsa1 - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have a project that contains both .f90, .f (FORTRAN) and C++ files. The C++ code calls functions in the fortran files.
I have installed the Intel Visual Fortran software.
What steps do i need to do in order to get the C++ and Fortran files to both be compiled when I choose 'build'? Do i need to specify a custom build rule for the FORTRAN files?
Is there a way to compile all the fortran code as a library then point to it in the project thru the linker? I tried making a dll using the Fortran code but received an error when I tried to compile the entire project (C++ plus Fortran DLL file). I also tried creating a .lib file using a Fortran project. This didn't work either.
I have pointed to the directory that the .lib and .dll file is in and am still getting the errors below.
Currently the project type is Visual C++. Is there another project type that supports multilanguage?
Any help is appreciated.
currently these are the errors I'm receiving. All functions are Fortran Functions
------ Build started: Project: adsa1, Configuration: Debug Win32 ------
Linking...
ADSAP.obj : error LNK2019: unresolved external symbol _LMDER1@48 referenced in function _AdsaLM
ELLIP.obj : error LNK2001: unresolved external symbol _LMDER1@48
ADSAP.obj : error LNK2019: unresolved external symbol _DPOSVM@28 referenced in function _AdsaNT
ADSAP.obj : error LNK2019: unresolved external symbol _ENORM@8 referenced in function _AdsaNT
PROFILE.obj : error LNK2019: unresolved external symbol _DVERK@40 referenced in function _DropProfileData
PROFILE.obj : error LNK2019: unresolved external symbol _INTRP@36 referenced in function _DropProfileIntrp
.\Debug/adsa1.exe : fatal error LNK1120: 5 unresolved externals
Build log was saved at "file://c:\Student\Kevin\AdsaInterf 3.0 source\Debug\BuildLog.htm"
adsa1 - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't mix Fortran and C++ code in a single project. To build a mixed-language application, you need a solution with two projects, one for each language. One of these will usually be an executable (or DLL) project and the other a static library.
Let's say that the main program is in C++ and the routines are in Fortran. Create your C++ project first in a new solution. Add the C++ files to it. Then add a new project of type Fortran > Static Library to the solution. Add the Fortran files to it. Now do the following:
- 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.
By the way, if you did have a CVF project with mixed sources, you can convert it to the split project solution automatically. See Migrating from Compaq* Visual Fortran
Let's say that the main program is in C++ and the routines are in Fortran. Create your C++ project first in a new solution. Add the C++ files to it. Then add a new project of type Fortran > Static Library to the solution. Add the Fortran files to it. Now do the following:
- 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.
By the way, if you did have a CVF project with mixed sources, you can convert it to the split project solution automatically. See Migrating from Compaq* Visual Fortran

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