Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

fortran calling c

fkaisermnb
Beginner
661 Views
Hi,
I still have the problem with a LNK2001unresolved external symbolerror (function defined in c an called by a fortran main):
program main
c====================================================
implicit none
include 'w23params.h'
INTERFACE
integer function inputw(a,b,c,d,e)
!DEC$ATTRIBUTES STDCALL,DECORATE,ALIAS:"inputw"::inputw
double precision a
double precision b
double precision c
double precision d
double precision e
END function
end interface
.....
subroutine Input(nsteps)
c===============================================
implicit none
include 'w23params.h'
integer nsteps,inputw
include 'w23comblk.h'

external inputw
nsteps = inputw(time,state,jtorque,sprforce,sprpt)
return
end
C-code:
/*==================================================
int __stdcall inputw_(double time[],double state[],double jtorque[],
double sprforce[],double sprpt[])
/*=================================================
....
I added the INTERFACE in the old code(I know that this program runs on another machine, but withoutthis interface and without __stdcall! )and the calling doesn't work.
I tried to remove the underscore in the definition of inputw in c, but that didn't work either.
Maybe the problem has something to do with wrong project-settings in the CVF-Compiler 6.6?
Christian
0 Kudos
4 Replies
TimP
Honored Contributor III
661 Views
Did you examine the .obj files with dumpbin /symbols to look for the discrepancy?
0 Kudos
fkaisermnb
Beginner
661 Views

I used the dumpbin/symbols commang, but to create the dump of the two .obj-files, but I don't know if there are aney discrepancies

Christian

0 Kudos
TimP
Honored Contributor III
661 Views
In your attached analysis, the Fortran .obj has the function named INPUTW, while the C has it named inputw_. I usually take the easy way around, making the adjustment with a #define inputw_ INPUTW on the C side.
0 Kudos
fkaisermnb
Beginner
661 Views

Thank's very much!! I added the define command in c and now it works.

Thank's, Christian

0 Kudos
Reply