cblas - unresolved external symbol referenced in function _main

193 Views Asked by At

For starters, I went through several similar asks and topics and found no answer (or didn't know how to apply it). I'm using VS 2019 and newest LAPACK. For starters, here's what I did so far:

  • downloaded LAPACK repo
  • changed the cmake file to also build cblas
  • used CMake to generate project
  • build said project (wouldn't let me launch it, so I guessed that that's how it's supposed to be done)
  • passed folder with header files to Include Directories (LIBPATH), folder with .lib files to Library Directories (LIB) and the .lib files themselves (lapack.lib, lapacke.lib, blas.lib, cblas.lib) as Additional Dependencies of the linker

Then attempted to launch the following code just to get hit with "unresolved external symbol _cblas_dgemv referenced in function _main":

#include<stdio.h>
#include<math.h>
#include<time.h>

#include <stdlib.h>

#include "cblas.h"
#include <complex>
#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
#include "lapacke.h"


#define n 2000
#define n2 n*n

int main()
{
    double* Af = (double*)calloc(n2, sizeof(double));

    double* x = (double*)calloc(n, sizeof(double));
    for (int i = 0; i < n; i++)
    {
        x[i] = i + 1;
    }

    double* b = (double*)calloc(n, sizeof(double));

    cblas_dgemv(CblasRowMajor, CblasTrans, n, n, 1, Af, n, x, 1, 0, b, 1);
    for (int i = 0; i < 20; i++)
        printf(" b%d = %f\n", i, b[i]);
}

Following some random advice found on the net I also tried changing compilation type from default to C but that one resulted wit literal thousands of errors from other dependencies (files such as "atomic", not quite sure but I suspect they come from base libraries).

0

There are 0 best solutions below