Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

problems of mixed program with fortran

$
0
0

I called a Fortran subroutine from a c++ project, in which the fortran subroutine is packed in an library created by the IVF. However, the link always fails with an error LNK2019. 

I set up an simple test project to simulate the problem. 

The fortran subroutine is a simple summation of integers:

    subroutine FSum(n,m,sum)
    implicit none
    integer :: n,m,sum
    sum = n+m
    end subroutine FSum

I create an IVF static librarry project Lib1F, set the runtime library->Multithread DLL (/libs:dll /threads) to compatible with the c++ project.

The c++ project contains an simple MyMain.cpp to test the mixed program

extern "C" 	void FSum(int *n, int *m, int *sum);
int main() {
	int n,m,sum;
n = 1; m = 2;
	FSum(&n,&m,&sum);}

I set the Linker->General->Additional Libraries Directories as the library output folder of the Fortran project Lib1F, and add the the Lib1F.lib to the Linker->Input->Additional Dependencies. 

The c++ projects always produce error:

1>------ Build started: Project: C++ (Intel C++ 14.0), Configuration: Release Win32 ------
1>ipo : warning #11021: unresolved _FSum
1>          Referenced in ipo_8272obj3.obj
1>ipo : error #11023: Not all components required for linking are present on command line
1>  xilink: executing 'link'
1>ipo_8272obj3.obj : error LNK2019: unresolved external symbol _FSum referenced in function _main

I am suing VS2012,Intel® C++ Composer XE 2013 SP1 Update 3,Intel(R) Visual Fortran Composer XE 2013 SP1 Update 3

The test projects are attached. Any comments are appreciated. 

 

 

AdjuntoTamaño
DescargarMixedProg.rar11.83 KB

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>