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

cblas, clapack Visual Studio 2003 .net, LNK2019

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

cblas, clapack Visual Studio 2003 .net, LNK2019

Postby Cristian » Mon Oct 16, 2006 12:40 pm

Hello to everybody!

I need to use cblas and clapack with Windows XP and Microsoft Visual Studio 2003 .net.

I've downloaded the package on http://www.netlib.org/clapack/CLAPACK3-Windows.zip. For one week I've been struggling with clapack and Visual Studio but without good results.

Here it the code that I have to build:

Code: Select all

#include "stdafx.h"
#include "stdlib.h"

#define _USE_MATH_DEFINES
#include <math.h>

extern "C" {
#include "c:\...\clapack\f2c.h"
#include "c:\...\clapack\blaswrap.h"
#include "c:\...\clapack\cblas.h"
}

using namespace std;
void main()
{
double **A, **B;
int i, col, row;
const int m=2, p=3, n=2;
const double alpha = 1, beta = 0;
double *pA, *pB;
double *pC;

A = new double*[m];
//allocate memory for p cols
for (i = 0; i < m; ++i)
    {
        A[i] = new double[p];
        };

// allocate memory for m rows
    B = new double*[p];

//allocate memory for p cols
    for (i = 0; i < p; ++i)
        {
            B[i] = new double[n];
            };

    for (row=0; row<m; row++)
        {
        for (col=0; col<p; col++)
            {
                A[row][col]=3*row+col+45;
                cout << A[row][col] << "   ";
            }
            cout << "\n";
        }
        cout << "\n";
    for (row=0; row<p; row++)
        {
        for (col=0; col<m; col++)
            {
                B[row][col]=2*row+col;
                cout << B[row][col] << "   ";
            }
        cout << "\n";
        }
    cout << "\n";

   pA = (double *) malloc(m * p * sizeof(double));
   pB = (double *) malloc(p * n * sizeof(double));
   pC = (double *) malloc(m * n * sizeof(double));

   i=0;
   for (row=0; row<m; row++)
    {
        for (col=0; col<p; col++)
            {
                //copy array into a row
                pA[i] = *(*(A+row)+col);
                i++;
            }
    }
   cout << "\n";

   i=0;
   for (row=0; row<p; row++)
        {
            for (col=0; col<n; col++)
            {
                //copy array into a row
                pB[i] = *(*(B+row)+col);
                i++;
                }
            }
           
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, m, p, n,
                                        alpha, pA, m, pB, p, beta, pC, m);
}



These are the libraries that I've added to my C++ console application code:

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


I don't understand why, but I've got the following error during linking:

cblas_dgemm_fcn error LNK2019: unresolved external symbol _cblas_dgemm referenced in function _main
cblas_dgemm_fcn fatal error LNK1120: 1 unresolved externals

Is there anyone who can help me to solve this problem?

Thank you in advance to anyone who would like to answer to this topic.

Kind regards,

Cristian

P.S. I rebuilt the blas and lapack libraries with my Visual Studio .net. Even using these new files I've got the error above....
Cristian
 
Posts: 1
Joined: Mon Oct 16, 2006 11:57 am

Postby kukuttou » Wed Nov 01, 2006 2:42 am

yeah, same here. I also have this problem
My complier is vc++ 2005.
Just like Cris, I downloaded the file at http://www.netlib.org/clapack/CLAPACK3-Windows.zip
Unzip, build the projects, test them. Everything is O.K. But without the good result, the problem jumps out.
I have tried the the sample code in section 1.9) of http://www.netlib.org/clapack/faq.html, the problem still there
For the win32 console application, I include the
f2c.h clapack.h
and link
blas.lib clapack.lib libF77.lib libI77.lib dgesvd.obj

And these are complains of my complier:

Linking...
main.obj : error LNK2019: unresolved external symbol "int __cdecl dgesvd_(char *,char *,long *,long *,double *,long *,double *,double *,long *,double *,long *,double *,long *,long *)" (?dgesvd_@@YAHPAD0PAJ1PAN122121211@Z) referenced in function _main
D:\myprog\lapacktest\Debug\lapacktest.exe : fatal error LNK1120: 1 unresolved externals

Did we miss anything?
:?:
kukuttou
 
Posts: 3
Joined: Wed Nov 01, 2006 1:16 am

Postby kukuttou » Wed Nov 01, 2006 4:25 pm

O.K.
I find a way out finally....phew.
select the project that will call the routine->open the project property pages->configuration preperties->c/c++->advanced
now, to the right, there is a " compile as" option.
DON'T select "compile as C++ code (/TP)", which is assumed by the compiler.
select the "compile as C code (/TC)".
then rebuild.
although there are warnnings about the missing *.pdb files, the linker works.
I still don't know the exact reason that causes the linking fail when compiled as c++. the conflict may come from the compiler if you use C libs, such as libF77.lib, blas.lib, with c++ code.
if your solution is in c++ and still want to use clapack, I think the way is writing a pure ANSI C project to call it and output the calculation result in a temporary file for further use.

good luck.
kukuttou
 
Posts: 3
Joined: Wed Nov 01, 2006 1:16 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 3 guests