Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran program calls C subroutine

Status
Not open for further replies.

saracooper

Programmer
May 1, 2010
3
IT
Hello, I am a C programmer, I have developed a set of subroutines in C and put them in a library, a .a file. These subroutines get called inside a Fortran program using CALL subroutine name.
I am working on IBM AIX. So the command I use to compile & link is -

xlf -o add.o -c liborac.a add.f
where liborac.a is the library with C subroutines

This gives me link errors saying my subroutines not found

The question is do I have some option missing to link these routines to the Fortran program. Or do I have to include the prototypes of the subroutines in the add.f program, like in C. Any help is appreciated. Thank you.
 
Have the C routines been defined as __stdcall? By default, they are defined as __cdecl.

Basically the difference is that in cdecl, the caller is responsible for pushing the parameters on to the stack and popping them off the stack.

In stdcall, the caller pushes them on to the stack but the callee pops them off.
 
Thanks for responding xwb. I am using the default - cdecl ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top