monkeycode
Technical User
I am trying a test build of some old code (hence the old compiler). I need to link C and F files, but I am getting the following error
error LNK2001: unresolved external symbol _flow
for each mention of a C file in the F code. Below is an example of how the f files link to the C files.
INTERFACE
SUBROUTINE flow (from, to, when, howmuch)
!MS$ATTRIBUTES C, ALIAS:'_flow' :: flow
REAL from
REAL to
REAL when
REAL howmuch
END SUBROUTINE flow
END INTERFACE
I am struggling to find any suggestions for the compiler I am using, but I suspect that the code is OK (I am assured the model has built from this code previously) and there is something wrong with what I am doing- I am wondering if I don't have the appropriate libraries to tell the compiler I am trying to link to C? I did attempt to download "fortran.h" and add this to my project file but this did not help, and when I added
include 'fortran.h'
to the relevant f files it caused syntax errors.
here is also the fortran.h file I am using
// Definitions for calling FORTRAN 77 from C++
typedef int INTEGER; // INTEGER 4 bytes
typedef float REAL; // REAL 4 bytes
typedef double DOUBLE_PRECISION; // DOUBLE PRECISION 8 bytes
typedef int LOGICAL; // LOGICAL 4 bytes
#include <f77char.h> // character n bytes
#include <f77cmplx.h> // complex
#include <f77matrx.h> // fmatrix class
// values for LOGICAL
#define FALSE 0
#define TRUE 1
// Macros for portable handling of linkage and calling conventions
//#ifdef F77_STUB_REQUIRED
// Typically, this branch is for Unix computers
// C++ stub functions:
#define SUBROUTINE inline void
#define INTEGER_FUNCTION inline INTEGER
#define REAL_FUNCTION inline REAL
#define LOGICAL_FUNCTION inline LOGICAL
#define DOUBLE_PRECISION_FUNCTION inline DOUBLE_PRECISION
// FORTRAN functions
#define SUBROUTINE_F77 extern "C" void
#define INTEGER_FUNCTION_F77 extern "C" int
#define REAL_FUNCTION_F77 extern "C" float
#define LOGICAL_FUNCTION_F77 extern "C" int
#define DOUBLE_PRECISION_FUNCTION_F77 extern "C" double
//#endif
// Array indexing differences between C++ and fortran
//#define B(i) b[i-1]
Thanks for reading- help greatly appreciated, and let me know if more information would be useful!
error LNK2001: unresolved external symbol _flow
for each mention of a C file in the F code. Below is an example of how the f files link to the C files.
INTERFACE
SUBROUTINE flow (from, to, when, howmuch)
!MS$ATTRIBUTES C, ALIAS:'_flow' :: flow
REAL from
REAL to
REAL when
REAL howmuch
END SUBROUTINE flow
END INTERFACE
I am struggling to find any suggestions for the compiler I am using, but I suspect that the code is OK (I am assured the model has built from this code previously) and there is something wrong with what I am doing- I am wondering if I don't have the appropriate libraries to tell the compiler I am trying to link to C? I did attempt to download "fortran.h" and add this to my project file but this did not help, and when I added
include 'fortran.h'
to the relevant f files it caused syntax errors.
here is also the fortran.h file I am using
// Definitions for calling FORTRAN 77 from C++
typedef int INTEGER; // INTEGER 4 bytes
typedef float REAL; // REAL 4 bytes
typedef double DOUBLE_PRECISION; // DOUBLE PRECISION 8 bytes
typedef int LOGICAL; // LOGICAL 4 bytes
#include <f77char.h> // character n bytes
#include <f77cmplx.h> // complex
#include <f77matrx.h> // fmatrix class
// values for LOGICAL
#define FALSE 0
#define TRUE 1
// Macros for portable handling of linkage and calling conventions
//#ifdef F77_STUB_REQUIRED
// Typically, this branch is for Unix computers
// C++ stub functions:
#define SUBROUTINE inline void
#define INTEGER_FUNCTION inline INTEGER
#define REAL_FUNCTION inline REAL
#define LOGICAL_FUNCTION inline LOGICAL
#define DOUBLE_PRECISION_FUNCTION inline DOUBLE_PRECISION
// FORTRAN functions
#define SUBROUTINE_F77 extern "C" void
#define INTEGER_FUNCTION_F77 extern "C" int
#define REAL_FUNCTION_F77 extern "C" float
#define LOGICAL_FUNCTION_F77 extern "C" int
#define DOUBLE_PRECISION_FUNCTION_F77 extern "C" double
//#endif
// Array indexing differences between C++ and fortran
//#define B(i) b[i-1]
Thanks for reading- help greatly appreciated, and let me know if more information would be useful!