The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Unresolved external with Visual C++ 6.0

Open discussion regarding features, bugs, issues, vendors, etc.

Unresolved external with Visual C++ 6.0

Postby Camus » Thu Jun 07, 2007 1:18 pm

Hi,

I have problems with my aplication, my code is:


/* Start of Listing */

#include "f2c.h"
#include "stdio.h"
#include "clapack.h"

#define SIZE 4

void MAIN_(){}
void MAIN__(){}
void _MAIN_(){}

main( )
{
char JOBU;
char JOBVT;

int i;

integer M = SIZE;
integer N = SIZE;

integer LDA = M;
integer LDU = M;
integer LDVT = N;
integer LWORK;
integer INFO;

integer mn = min( M, N );

integer MN = max( M, N );

double a[SIZE*SIZE] = { 16.0, 5.0, 9.0 , 4.0, 2.0, 11.0, 7.0 , 14.0, 3.0, 10.0, 6.0, 15.0, 13.0, 8.0, 12.0, 1.0};
double s[SIZE];
double wk[201];
double uu[SIZE*SIZE];
double vt[SIZE*SIZE];

JOBU = 'A';

JOBVT = 'A';

LWORK = 201;

/* Subroutine int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n,
doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
integer *info)
*/

dgesvd_( &JOBU, &JOBVT, &M, &N, a, &LDA, s, uu,
&LDU, vt, &LDVT, wk, &LWORK, &INFO);

printf("\n INFO=%d", INFO );

for ( i= 0; i< SIZE; i++ ) {
printf("\n s[ %d ] = %f", i, s[ i ] );
}

return 0;
}

/* End of Listing */


This a exemple in section 1.9, but when i trate to crate executable file i obteind:

Linking...
laplack.obj : error LNK2001: unresolved external symbol "int __cdecl dgesvd_(char *,char *,long *,long *,double *,long *,double *,double *,long *,double *,long *,double *,long *,long *)" (?dgesvd_@@YAHPAD0PAJ1PAN122121211@Z)
Debug/laplack.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

laplack.exe - 2 error(s), 0 warning(s)

I compiled and added the next libraries:

- clapack.lib
- libF77.lib
-libI77.lib
- blas.lib

Somebody help me about this problem?

Thanks.
Camus
 
Posts: 2
Joined: Thu Jun 07, 2007 1:10 pm

Postby Camus » Fri Jun 15, 2007 4:38 pm

I navegate in the forum, I think so that problem is in the clapack.lib, any person works with VISUAL STUDIO 6.0 and solve this problem?

:shock:
Camus
 
Posts: 2
Joined: Thu Jun 07, 2007 1:10 pm

use extern "C"

Postby neo.patrix » Tue Sep 25, 2007 3:15 am

When working VC++ create a separate header for all the clapack functions that
you need to use from clapack.h. Please keep you clapack.h unchanged whenever possible.

Now in the new header, should be in fromat like

Code: Select all
#include "stdlib.h"
.....

namespace LAPACK {

// copy required types from f2c.h

extern "C" {

// copy required function definitions from clapack.h
// this is necessary because VC++ complier will add many extra characters
// to original function name based on inputs & outputs. But clapack.lib
// has pure C-style function definition , hence linking is impossible

}

}

// you program
#include "mylapack.h"

myFunc()
{
...
...
::LAPACK::<clapack function or datatype>
}

neo.patrix
 
Posts: 2
Joined: Tue Sep 25, 2007 3:01 am
Location: Friedrichshafen, Germany


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests