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

which header files to be used: Urgent

rampy
Beginner
299 Views
Hi , I am been trying to compile a code in intel fortran compiler which call a C function. Both these are integrated in Microsoft Visual Studio.net 2003. the C compiler is defuat visual C++ compiler.



My code is given below



PROGRAM f_calls_c

IMPLICIT NONE

REAL R

REAL :: p1_x, p1_y, p2_x, p2_y

EXTERNAL CALC_DIST



p1_x = 0.0

p1_y = 0.0

p2_x = 3.0

p2_y = 4.0







CALL CALC_DIST(p1_x,p1_y,p2_x,p2_y)

READ(*,*)R

WRITE(*,*)R





END PROGRAM f_calls_c



#include

#include

#include



extern "C" void calc_dist_(float *x1, float *y1, float *x2, float *y2)

{

float dxsq, dysq, distance, read;



dxsq = (*x2-*x1)*(*x2-*x1);

dysq = (*y2-*y1)*(*y2-*y1);



distance = sqrt( dxsq + dysq );



printf("The distance between the points is %13.5e ",

distance);



}



The error i get is

callC.obj : error LNK2019: unresolved external symbol _CALC_DIST referenced in function _MAIN__

Debug/callC.exe : fatal error LNK1120: 1 unresolved externals





PLEASE suggest some solution..I have to get started with my project.Not able to figure out from the forum previous messages!!!!
0 Kudos
3 Replies
Steven_L_Intel1
Employee
299 Views
Solution 1: Rename the C function to be CALC_DIST.
Solution 2: Add to the Fortran code:

!DEC$ ATTRIBUTES ALIAS:"_calc_dist" :: CALC_DIST

You can (and should) remove the EXTERNAL statement, since CALC_DIST is not a function.
0 Kudos
rampy
Beginner
299 Views


sblionel wrote:
Solution 1: Rename the C function to be CALC_DIST.
Solution 2: Add to the Fortran code:

!DEC$ ATTRIBUTES ALIAS:"_calc_dist" :: CALC_DIST

You can (and should) remove the EXTERNAL statement, since CALC_DIST is not a function.


Hi,

I tried using both solution but still I get the same error..I think I need to change some settings in Microsoft Visual Studio .net Could you suggest some solutions .which is the best way.
I have intel fortran compiler 9 which is installed in Microsoft Visual studio net 2003. I tired using the command
CL -c filename.C
ifort filename.obj fortran_filename.f90
Still the same error!!!

Thanks a ton in advance
0 Kudos
rampy
Beginner
299 Views
Thanks a ton Sblionel for the solution..The program runs through command promt...Now I can proceed further to pass various arguments..







Finally I can kick start on my project...







rampy







" If you have Dreams, Don't Sleep!!!.."

Message Edited by rampy on 10-16-2005 07:02 AM

Message Edited by rampy on 10-16-2005 07:02 AM

0 Kudos
Reply