Hi,
I am trying to run a simple c++ code I wrote to practise calling a simple FORTRAN function.
The c++ code is in main.cpp:
[cpp]#include
using namespace std;
extern"C" {
void fortfunc_(int *ii, float *ff);
}
int main()
{
int ii=5;
float ff=5.5;
fortfunc_(&ii, &ff);
return 0;
}[/cpp] and the fortran function is in fortran.f90:
[fortran] subroutine fortfunc(ii,ff)
integer ii
real*4 ff
write(6,100) ii, ff
100 format('ii=',i2,' ff=',f6.3)
return
end[/fortran] Anyway, the problem is at the linking stage. I use icc to compile main.cpp -> main.o then ifort to compile fortran.f90 -> fortran.o
Then I attempt to link with icc like this:
icc -o prog main.o fortran.o -lifcore -limf
but I get the following linker problems:
ld: warning: libintlc.so.5, needed by /opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libifcore.so.5, not found (try using -rpath or -rpath-link)
ld: prog: hidden symbol `__intel_cpu_indicator_init' in /opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libirc.a(cpu_disp.o) is referenced by DSO
ld: final link failed: Nonrepresentable section on output
(1) The first warning is strange, as I have verified the library libintlc.so.5 is in the directory it mentions:
/opt/intel/composer_xe_2011_sp1.8.273/compiler/lib/intel64/libifcore.so.5
According to the man page the option -L allows you to specify a search directory for libraries - I tried the above directory and that didn't help.
(2) and (3) I don not understand what these errors mean, can someone lend a hand?
Cheers,
Mark