473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

c calling a fortran subroutine

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
1 3138
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NM | last post by:
Hello All I am writing some progam that involves both C++ and Fortran. Some of the existing code is in Fortran. The main program will be in C++ and it will call some Fortran subroutine. All the...
6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it this way as our build process does not allow...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
2
by: NM | last post by:
Hello all, I am supposed to do some mixed programming with c++ and fortran. I was succeeful in exchanging the 2D arrays from fortran to c++ and the other way, but was unable to that same with...
12
by: Bigdakine | last post by:
I don't know if this is the right forum for this, and if not please suggest one which fits. I have to call a fortran sub routine from a C main program. The fortran subroutine statement is ...
5
by: Amit | last post by:
I tried calling a subroutine in a fortran module from C ,but couldn't.I always get the error: undefined reference in the main.o file (main is in C calling the subroutine). for calling the...
2
by: Ray J. | last post by:
I have a C++ program written and compiled on Solaris 8 with gcc. With gcc lets me compile fortran code along with the C++ program to be able to call the fortran code as a subroutine. The...
11
by: RichN | last post by:
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...
21
by: Cottonwood | last post by:
I want to call a C module from a Fortran program. Whatever I tried - the linker could not find the C module. I know about the leading underscore and switched even that off. I abstracted everything...
4
by: nitusa | last post by:
Hey Everyone, I am doing a VB6 to C# conversion and everything was going smoothly until I realized that I needed to call a Fortran 77 (.for) .dll inside my code. I have looked through everything...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.