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

error LNK2028

Mike896
Beginner
929 Views
Hi,

I use VS2008. I use a C program to call a Fortran static library.
I had an error LNK2028.

I have many statements before main() like:
extern void _stdcall SUBA(int *a,float *b);

I am wondering how to resolve this.

Mike
0 Kudos
3 Replies
Arjen_Markus
Honored Contributor II
929 Views
The link error seems to be related to the calling convention. What happens if you replace
_stdcall by _cdecl (or remove it altogether)? For Intel Visual Fortran the default calling convention
is _cdecl, IIRC, and it is almost always a bad idea to mess with it.

Regards,

Arjen
0 Kudos
mecej4
Honored Contributor III
929 Views
Why do you have the "_stdcall" attribute? How do you compile the C and Fortran sources?

If the "_stdcall" was used with an older compiler for which it was appropriate, simply remove it, compile the C source(s) and try linking again.
0 Kudos
Mike896
Beginner
929 Views
Hi,
Thank you for the reminder.
I had this compiled in HP UNIX workstation about 15 years ago and it's OK. I don't have much experience about C.

In the C main program, I have now

#include

#include   /* Are these ok? I know there is some .

#include

#include

#include
Then have some
#define constants ....
Then I have some calling conventions as:
extern void _cdecl SUBA(int *a,float *b); /* replace _stdcall, but I still have  error LNK2028 */

First, I create a Fortran library project and add all those subroutines and functions in it. I also remember to specify the "Additional Include Directories" specified in "XXX Property Pages"/Configuration Properties/Fortran/Preprocessor.
Secondly, I create a Visual C++ project with CLR empty project. I also specify "Additional Include Directories" but no Preprocessor. I also specify Linker(I use Chinese version of VS2008)/Input/Additional Dependency as the Path/MyFortran.lib and also a NumericalFortranRecipe.lib. I also have /clr /TP options.

I don't know what's the difference between _cdecl and _stdcall. I surf a little and find something which is about stack.
Thanks for helping me.

Mike

0 Kudos
Reply