G
Guest
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled
within Visual Studio .NET 2003). Am trying to link simple c++ code to
fortran dlls created in Compaq Visual Fortran (v6.1). Posts concerning
this topic are common, but none of the posted solutions I've tried work
correctly with the above software. The linker can't seem to find the dll
(reports 'unresolved external symbol __imp__IMSL_FUN@8'; IMSL_FUN.dll is
the f77 library), although the library exists, compiled fine within CVF,
and its directory is declared in Visual C++'s Project|Properties
|Linker|Additional Library Directories. I'm hoping this is a simple
problem. The f77 and c++ source code is extremely simple and is included
below along with both the CVF and VS7 C++ compiler/linker messages,
! ------------------ begin f77
! imsl_fun.for
!
! FUNCTIONS/SUBROUTINES exported from IMSL_FUN.dll:
! IMSL_FUN - subroutine
!
double precision function IMSL_FUN(A,B)
! Expose subroutine IMSL_FUN to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::IMSL_FUN
implicit none
double precision A, B
IMSL_FUN = A / B
return
end
! ------------------ end f77
Compiling Fortran...
C:\home\rolf\local\lib\imsl_fun\IMSL_FUN.for
Linking...
Creating library Debug/imsl_fun.lib and object Debug/imsl_fun.exp
imsl_fun.dll - 0 error(s), 0 warning(s)
// ------------------ begin c++
// testIMSL.NET.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
extern "C" __declspec(dllimport) short __stdcall IMSL_FUN(double* a, double*
b);
int _tmain(int argc, _TCHAR* argv[])
{
double y = -1.e-12;
double a, b;
a = 1.;
b = 1.;
std::cout << "Before calling IMSL_FUN y = " << y << std::endl;
y = IMSL_FUN(&a, &b);
std::cout << "After calling IMSL_FUN y = " << y << std::endl;
return 0;
}
// ------------------ end c++
Compiling...
testIMSL.cpp
Linking...
testIMSL.obj : error LNK2019: unresolved external symbol __imp__IMSL_FUN@8
referenced in function _main
Debug/testIMSL.exe : fatal error LNK1120: 1 unresolved externals
testIMSL.NET - 2 error(s), 0 warning(s)
Any ideas?
within Visual Studio .NET 2003). Am trying to link simple c++ code to
fortran dlls created in Compaq Visual Fortran (v6.1). Posts concerning
this topic are common, but none of the posted solutions I've tried work
correctly with the above software. The linker can't seem to find the dll
(reports 'unresolved external symbol __imp__IMSL_FUN@8'; IMSL_FUN.dll is
the f77 library), although the library exists, compiled fine within CVF,
and its directory is declared in Visual C++'s Project|Properties
|Linker|Additional Library Directories. I'm hoping this is a simple
problem. The f77 and c++ source code is extremely simple and is included
below along with both the CVF and VS7 C++ compiler/linker messages,
! ------------------ begin f77
! imsl_fun.for
!
! FUNCTIONS/SUBROUTINES exported from IMSL_FUN.dll:
! IMSL_FUN - subroutine
!
double precision function IMSL_FUN(A,B)
! Expose subroutine IMSL_FUN to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::IMSL_FUN
implicit none
double precision A, B
IMSL_FUN = A / B
return
end
! ------------------ end f77
Compiling Fortran...
C:\home\rolf\local\lib\imsl_fun\IMSL_FUN.for
Linking...
Creating library Debug/imsl_fun.lib and object Debug/imsl_fun.exp
imsl_fun.dll - 0 error(s), 0 warning(s)
// ------------------ begin c++
// testIMSL.NET.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
extern "C" __declspec(dllimport) short __stdcall IMSL_FUN(double* a, double*
b);
int _tmain(int argc, _TCHAR* argv[])
{
double y = -1.e-12;
double a, b;
a = 1.;
b = 1.;
std::cout << "Before calling IMSL_FUN y = " << y << std::endl;
y = IMSL_FUN(&a, &b);
std::cout << "After calling IMSL_FUN y = " << y << std::endl;
return 0;
}
// ------------------ end c++
Compiling...
testIMSL.cpp
Linking...
testIMSL.obj : error LNK2019: unresolved external symbol __imp__IMSL_FUN@8
referenced in function _main
Debug/testIMSL.exe : fatal error LNK1120: 1 unresolved externals
testIMSL.NET - 2 error(s), 0 warning(s)
Any ideas?