[Intel Compiler 8.1] C++ calling Fortran Routine



 DEVELOP > c-Plus-Plus > [Intel Compiler 8.1] C++ calling Fortran Routine

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Sascha T."
Date: 16 Feb 2005 07:43:31 AM
Object: [Intel Compiler 8.1] C++ calling Fortran Routine
Hi!
I have desperately searched google and its groups in vain. Hope you can
help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.
Compilers are properly installed and working, means, 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<iostream>
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
.

User: "Tim Prince"

Title: Re: [Intel Compiler 8.1] C++ calling Fortran Routine 16 Feb 2005 08:39:34 AM
"Sascha T." <djiwehweuhfwei@spammotel.com> wrote in message
news:pan.2005.02.16.13.43.31.528316@spammotel.com...


Hi!

I have desperately searched google and its groups in vain. Hope you can
help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, means, 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<iostream>
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!

If the compiled objects make calls to a run-time library which came with a
Fortran compiler earlier than ifort 8.0, you will need that library, and you
will not be able to use ifort. You will need also a great deal of luck, and
avoidance of file usage conflicts between your code and the invisible
Fortran. If the objects are actually compatible with ifort, you could link
with ifort, but you need to know the additional libraries involved in icpc
linkage. This will depend on several factors, including whether you are
running 32-bit or one of the 64-bit versions of linux, and whether your icpc
was installed on top of a working g++. For example, I have a project which
requires
ifort *.o -lstdc++ -lunwind -lcxa
on one of those linux versions.
.
User: "Sascha T."

Title: Re: [Intel Compiler 8.1] C++ calling Fortran Routine 16 Feb 2005 08:47:42 AM
OF COURSE! Dump me, thanks for the hint!
I recompiled the .f-object and, using icpc for linking, I added
-L[ifort8.1path]/lib -lifcore
ending up in a successful binary.
Thank you!
Cheers
Am Wed, 16 Feb 2005 14:39:34 +0000 schrieb Tim Prince:

For example, I have a project which
requires
ifort *.o -lstdc++ -lunwind -lcxa
on one of those linux versions.

.


User: "Shezan Baig"

Title: Re: [Intel Compiler 8.1] C++ calling Fortran Routine 16 Feb 2005 08:21:07 AM
Sascha T. wrote:

Hi!

I have desperately searched google and its groups in vain. Hope you

can

help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, means, 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<iostream>
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

Looks like you're missing some libraries used by your fortran compiler.
-shez-
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER