By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

c calling a fortran subroutine

P: n/a
I am developing a c program in Visual Studio .NET 2003. I also have an
Intel(R) Fortran compiler for MVS .NET

My fortran sourcecode already existed. I started a new fortran project and
chose to create a dynamic link library. The beginning of the fortran code
looks like:

SUBROUTINE SFTCK3
!DEC$ ATTRIBUTES DLLEXPORT::SFTCK3

It compiled ok, and created both a SFTCK3.lib and SFTCK3.dll

In the C code, I've tried a variety of online suggestions, but for now it
looks like:
(from top)

#include <stdio.h>
#include <process.h>
#include <iostream.h>
#include "SelectOp.h"
#include "SelectOpGui.h"

extern void _stdcall SFTCK3 (void);

later on, in the code, i call:

case 8:

SFTCK3();
break;

I get the following error when trying to build:

error LNK2019: unresolved external symbol _SFTCK3@0 referenced in function
_SelectOp_OnOperation, which would be the call made above.

In the c codes' property settings, i do have, under additional dependencies:

c:\Temp\FAST_CSCI\SFTCK3\SFTCK3.lib

I'm pretty sure it's because I'm not linking the c and fortran together, but
not sure how to get this working. Any help would be appreciated. Thanks
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
RichN wrote:
I am developing a c program in Visual Studio .NET 2003. I also have an
Intel(R) Fortran compiler for MVS .NET

My fortran sourcecode already existed. I started a new fortran
project and chose to create a dynamic link library. The beginning of
the fortran code looks like:

SUBROUTINE SFTCK3
!DEC$ ATTRIBUTES DLLEXPORT::SFTCK3

It compiled ok, and created both a SFTCK3.lib and SFTCK3.dll

In the C code, I've tried a variety of online suggestions, but for
now it looks like:
(from top)

#include <stdio.h>
#include <process.h>
#include <iostream.h>
#include "SelectOp.h"
#include "SelectOpGui.h"

extern void _stdcall SFTCK3 (void);

later on, in the code, i call:

case 8:

SFTCK3();
break;

I get the following error when trying to build:

error LNK2019: unresolved external symbol _SFTCK3@0 referenced in
function _SelectOp_OnOperation, which would be the call made above.

In the c codes' property settings, i do have, under additional
dependencies:

c:\Temp\FAST_CSCI\SFTCK3\SFTCK3.lib

I'm pretty sure it's because I'm not linking the c and fortran
together, but not sure how to get this working. Any help would be
appreciated. Thanks


Use dumpbin /symbols on your STFCK3.lib import library to see what the
exported symbol name is. That'll give a clue to the solution (which
probably involves changing the name you use in the C code, or in the Fortran
code, or changing calling convention, or some such).

-cd
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.