473,714 Members | 3,850 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::SFTC K3

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 "SelectOpGu i.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_OnOpe ration, which would be the call made above.

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

c:\Temp\FAST_CS CI\SFTCK3\SFTCK 3.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 3245
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::SFTC K3

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 "SelectOpGu i.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_OnOpe ration, which would be the call made above.

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

c:\Temp\FAST_CS CI\SFTCK3\SFTCK 3.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
2854
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 memory allocation has to be done in C++. For arrays of structures and arrays (including multi-dimensional array) of primitive data types declared in Fortran, I know the corresponding data structures in C++. So I can declare those data structures...
6
3527
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 circular dependencies of DLL's. Does anyone know how to do this, I have tried everything in my book. I have a C++ function GetP: DllExport void GetP()
1
6432
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 the array in fortran and then accessing it in my c++ code. Say in my c++ code I have; extern "C" { void foo_(float **, int &, int &); }
2
3321
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 the 3D arrays, the values passed are not all the same. I am also pasting the fortran and c++ codes so that you could have a look at them. ////C++ Code
12
2897
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 wload(starttime, duration, station, component, dataray, nsamp, calib, srate, samplength, datadir)
5
4350
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 subroutine I used the following name: modulename_MP_subroutinename_(...) and all possible variant (upper case,lower case).Can anybody help (for a unix system)
2
2823
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 specifications for this project have changed and I am porting the C++ code to Visual C++. Is there a way to call fortran code from a C++ program compiled with Visual C++?
11
543
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 create a dynamic link library. The beginning of the fortran code looks like: SUBROUTINE SFTCK3 !DEC$ ATTRIBUTES DLLEXPORT::SFTCK3
21
2756
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 possible. When I replace the C module by a Fortran subroutine linking works. Here the Fortran subroutine that replaced the C module for testing: subroutine qqcprint return end
4
2307
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 I have found using Google and have still been unable to get it to successfully work. Currently the following call works about 75% of the time, but the other 25% of the time my program just calls the .dll and then it simply exits; no...
0
8808
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9316
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6637
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3159
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.