Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

C++ calling Fortran Routine

saschat
Beginner
774 Views
Hi!

I have been desperately searching google and its groups in vain. Hope you can help. I need to call some ancient fortran objects from C++-main program using the latest intel compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, i.e. LD_LIBRARY_PATH and PATH is set correctly.

Calling Fortan (example.f) from C (main.c) works fine using

> icc -c main
> ifort -o main main.o function.f -nofor_main

However, C++ seems to have some problems. Here are the codes:

----- FORTRAN: function.f -----

SUBROUTINE fortrantest()
IMPLICIT NONE
PRINT *, "Simple test o.k."
END

----- C++: main.C ----------

#include
using namespace std;

extern "C"
{
extern void fortrantest_();
}

int main()
{
cout "Testing call" endl;
fortrantest_();
}

----------------------

using

> icpc -c main.C
> ifort -c function.f -nofor_main

works without errors, but linking with

> ifort -o main function.o main.o -nofor_main main.o

produces lots of undefined refs. icpc produces different
and fewer error-messages

> icpc -o main function.o main.o
function.o(.text+0x36): In function `fortrantest_':
: undefined reference to `for_write_seq_lis'


Any suggestions welcome!

Thanx

ST
0 Kudos
1 Reply
saschat
Beginner
774 Views
O.k., my problem has been solved... I needed to tell icpc the path to ifcore and explicitly link it.

Cheers
0 Kudos
Reply