Linking Fortran Libs with VC++.NET

Linking Fortran Libs with VC++.NET

erincatto's picture

I'm trying to link and run some simple code with BLAS and LAPACK libraries built with CVF 6.5. It links fine in VC++.NET, but I get a "runtime error" message before I reach main().

The same code runs fine with VC++6.0.

Does anyone know what's wrong?

Thanks,
Erin

===========
extern "C" void __stdcall
DAXPY(int *n, double* a, double* x, int* incx, double* y, int* incy);

extern "C" void __stdcall
DGETRF(int* m, int* n, double* A, int* lda, int* ipiv, int* info);

int
main()
{
double a, *x, *y;
int n, inc;

inc = 1;
n = 3;
a = 2.0;

x = new double[n];
y = new double[n];

x[0] = 2.0; x[1] = -1.0; x[2] = 1.0;
y[0] = 5.0; y[1] = 2.0; y[2] = -3.0;

DAXPY(&n, &a, x, &inc, y, &inc);

double *A = new double[n*n];

A[0] = 1.0; A[3] = 5.0; A[6] = -2.0;
A[1] = -1.0; A[4] = 9.0; A[7] = 3.0;
A[2] = -7.0; A[5] = 2.0; A[8] = 10.0;

int *ipiv = new int[3];
int info = 0;

DGETRF(&n, &n, A, &n, ipiv, &info);

delete [] x;
delete [] y;
delete [] A;
delete [] ipiv;

return 0;
}

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

Where do your BLAS and LAPACK routines come from?

Steve

Steve
erincatto's picture

Its actually linking with LAPACK that causes problems. Linking with BLAS alone works. The LAPACK library was built in CVF 6.5 from LAPACK 3.0 Fotran files from www.netlib.org.

Right now I'm going to experiment with breaking the library up into smaller pieces.

erincatto's picture

I've reduced the problem to a small size. I downloaded only the files I need for DGETRF.F from netlib. I put together a .NET project and a CVF 6.5 project. These files are attached. The only settings to change is the location of the Fortran libs in the .NET project.

This still produces the same runtime error before main() is reached.

Erin

Steve Lionel (Intel)'s picture

Erin,

I tried your example using CVF 6.6A and VC.NET. It worked fine. No run-time errors.

Steve

Steve

Login to leave a comment.