Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
31 Views

Trouble using a fortran static library in C++

Hello everyone.

I have a fortran static library which I need to call from C++. I added the library to the C++ project and when I run the programI get this:

error LNK2019: símbolo externo Coresolver sin resolver al que se hace referencia en la función main.

 

This is my code:

extern "C"{
	void Coresolver
		(int *Puntosnp,
		int *PuntosKr,
		double *Sw,
		double *Kro,
		double *Krw,
		double *Vp,
		double *Npcalc,
		double *DeltaPcalc);
}


int main()
{
	int Puntosnp = 2;
	int PuntosKr = 2;
	double Sw[2];
	double Krw[2];
	double Kro[2];
	double Vp[2];
	double Npcalc[2];
	double DeltaPcalc[2];

	Sw[0] = 0.2, Sw[1] = 0.8;
	Krw[0] = 0.0, Krw[1] = 0.8;
	Kro[0] = 0.8, Kro[1] = 0.0;
	Vp[0] = 0.2, Vp[1] = 1.0;
	Npcalc[0] = 0.0, Npcalc[1] = 0.0;
	DeltaPcalc[0] = 0.0, DeltaPcalc[1] = 0.0;

	Coresolver(&Puntosnp, &PuntosKr, Sw, Kro, Krw, Vp, Npcalc, DeltaPcalc);
	return 0;
}

 

0 Kudos
3 Replies
Highlighted
Black Belt
31 Views

The names of Fortran external symbols are subject to "decoration", i.e., changing of case and adding an underscore as a prefix, depending on whether the code is for a 32-bit CPU or a 64-bit CPU. If you did not use the ISO-C interoperability features or the "legacy" directives when you built the Fortran library, the C name should be  "CORESOLVER" for 64-bit and "_CORESOLVER" for 32-bit. For details, see the Intel Fortran documentation.

0 Kudos
Highlighted
Beginner
31 Views

Hi.

Thnaks, that worked. But I´m having other problem, Npcalc and DeltaPcalc are arrays and when I call CORESOLVER they should change their values but they remain in value cero.

0 Kudos
Highlighted
Black Belt
31 Views

You will have to show the Fortran source code of CORESOLVER (or at least the parts of it that set Npcalc and DeltaPcalc) in order for us to see what could have happened.

0 Kudos