Question

I'm relatively new to C++ (I mainly have a C# background). I've been given some code that is to be ported from Windows to Linux, but while I can get Visual Studio 2010 to compile it (with the Intel C++ compiler), I can't get it to work either with gcc in linux, or the Intel C++ Linux compiler (both give the same error). I don't think it's an Intel specific function that's not working, which is why I'm asking here instead of on the Intel forums.

The file DoubleMatrixOperations.cpp that I'm trying to compile is:

#include <ipp.h> 
#include <mkl.h> 

extern "C" 
{ 
void Multiply_mdvd_vd(int rows, int cols, double* vout, double* m, double* v, bool transpose) 
{ 
cblas_dgemv( 
CBLAS_ORDER::CblasRowMajor, 
transpose ? CBLAS_TRANSPOSE::CblasTrans : CBLAS_TRANSPOSE::CblasNoTrans, 
rows, cols, 1.0, m, cols, v, 1, 0.0, vout, 1); 
} 
}

The output from the compiler is:

$ gcc DoubleMatrixOperations.cpp -I$IPPROOT/include
DoubleMatrixOperations.cpp: In function âvoid Multiply_mdvd_vd(int, int, double*, double*, double*, bool)â:
DoubleMatrixOperations.cpp:9:4: error: âCBLAS_ORDERâ is not a class or namespace
DoubleMatrixOperations.cpp:10:16: error: âCBLAS_TRANSPOSEâ is not a class or namespace
DoubleMatrixOperations.cpp:10:46: error: âCBLAS_TRANSPOSEâ is not a class or namespace

Apologies in advance if this is a stupid question!

Thanks, Thomas

Was it helpful?

Solution

Edit: As hivert correctly pointed out in the comment section, this problem doesn't exist when you are using C++11. The solution below applies to older compilers though.


Since CBLAS_ORDER and CBLAS_TRANSPOSE are enums, not classes/namespaces, they don't introduce the scope. That's why you should remove the name qualifiers:

cblas_dgemv(CblasRowMajor, transpose ? CblasTrans : CblasNoTrans, rows, cols, 1.0, m, cols, v, 1, 0.0, vout, 1);

However, VC compiler should compile this code, but it should also print some warning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top