- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have been spending a day now trying to make my program run. I have Microsoft Visual Studio with the Intel Fortran Compiler installed. The majority of my program is Fortran, but it needs to be compiled with a C (or C++) file. My solution consists of two projects, one for Fortran and the other for C (defined asa Windows Static Library). The error message I keep on getting is:
2>t2f.obj : error LNK2019: unresolved external symbol _CPUCLK referenced in function _CPUINI
CPUCLK is defined in the C file, while CPUINI is the Fortran routine that refers to CPUCLK. The following line is present in the C-file:
double __stdcall CPUCLK()
The static library file is made and found (when not present its reports this), but still the two languages do need seem to talk. I got the code from someone else and there it worked, so I guess it is a linker problem.I tried a lot of things, as the LNK2019 problem is discussed on various forums.
I hope that anyone can give me advise. Thank you very much!
Tim
I have been spending a day now trying to make my program run. I have Microsoft Visual Studio with the Intel Fortran Compiler installed. The majority of my program is Fortran, but it needs to be compiled with a C (or C++) file. My solution consists of two projects, one for Fortran and the other for C (defined asa Windows Static Library). The error message I keep on getting is:
2>t2f.obj : error LNK2019: unresolved external symbol _CPUCLK referenced in function _CPUINI
CPUCLK is defined in the C file, while CPUINI is the Fortran routine that refers to CPUCLK. The following line is present in the C-file:
double __stdcall CPUCLK()
The static library file is made and found (when not present its reports this), but still the two languages do need seem to talk. I got the code from someone else and there it worked, so I guess it is a linker problem.I tried a lot of things, as the LNK2019 problem is discussed on various forums.
I hope that anyone can give me advise. Thank you very much!
Tim
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On 32-bit Windows system __stdcall calling convention will make function "CPUCLK" have symbol name"_CPUCLK@0" -- http://msdn.microsoft.com/en-us/library/zxk0tw93%28VS.80%29.aspx
If you want to keep this calling convention in the C file its declaration in the Fortran code should have attributes STDCALL as:
cDEC$ ATTRIBUTES STDCALL
If you want to keep this calling convention in the C file its declaration in the Fortran code should have attributes STDCALL as:
cDEC$ ATTRIBUTES STDCALL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two problems here: one almost certain and the other possible.
The listing will end up in temp.txt. For examining dlls, use Dependency Walker.
- With Intel Fortran (and all other current compilers), the default calling convention is __cdecl, not __stdcall (as used to be in Compaq Visual Fortran days). Thus, you either need to change that in the C code (recommended) or change the Fortran compiler setting (/iface:cvf, adjustable in "External procedures" category of the project settings).
- You need to make sure that the function does not have C++ name decoration, either by enclosing it in an extern "C" block, or naming the source files .c (rather than .cpp).
[bash]dumpbin /symbols yourfile.obj > temp.txt[/bash]
The listing will end up in temp.txt. For examining dlls, use Dependency Walker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi thank you both for your suggestions!
I replaced the command __stdcall by __cdecl and that worked!
Thank you very much for the solution!
Tim
I replaced the command __stdcall by __cdecl and that worked!
Thank you very much for the solution!
Tim
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page