- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
_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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
#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

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