- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am able to build my application, which is a mixed C/Fortran application, on windows without problems using icl and ifl (7.1)
However, when I port the source code to Linux, I cannot have my C functions linked to the Fortran objects. Below is small mixed C/F9x application that illustrates what I experience in my original application.
There is a "main.for" which calls a C function (fact.c) to compute the factorial of an integer.
When linking the objects with ifc 7.1, I get the following error.
$> ifc src/main.o src/fact.o -o src/fact -lcxa -C90
src/main.o(.text+0x20): In function `main':
: undefined reference to `FACT2'
Here are the files. My linux box is RH 8.0. Any help would be truly appreciated. Note, the function name in fact.c is (deliberately) aliased and made uppercase.
C-- file 1: main.for --
CCCCCCCCCCCCCCCCCCCCC
MODULE CFACT
INTERFACE
INTEGER FUNCTION FACT( N)
!MS$ ATTRIBUTES C,ALIAS:'FACT2'::FACT
INTEGER N [REFERENCE]
END FUNCTION FACT
END INTERFACE
END MODULE
CCCCCCCCCCCCCCCCCCCCCC
program main
use CFACT
implicit none
integer f1,f2,f3
f1 = FACT(10)
write (*,*) 'fact = ', f1
stop
end
/**** file 2: fact.c *****/
int FACT2( int *n)
{
int i, f = 1;
for (i=1;i<=*n;i++) f = f * i;
return f;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. You suggestion solved the issue.
Regards
MA

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page