2016-04-23 89 views
1

如果我不包括<lapacke.h>,我得到以下錯誤:lapacke與boost有衝突嗎?

test.cpp:20:23: error: ‘LAPACK_ROW_MAJOR’ was not declared in this scope 
    LAPACKE_dsyev(LAPACK_ROW_MAJOR, jobz, uplo, N, &a[0], lda, &work[0]); 
       ^
test.cpp:20:76: error: ‘LAPACKE_dsyev’ was not declared in this scope 
    LAPACKE_dsyev(LAPACK_ROW_MAJOR, jobz, uplo, N, &a[0], lda, &work[0]); 

然而,當我包括<lapacke.h>,我得到的錯誤與boost衝突的一個長長的清單。我相信這是包括<boost/algorithm/string.hpp>,因爲這是我使用的唯一的boost項目。

lapackeboost有衝突嗎?當我離開<boost/algorithm/string.hpp>它編譯好,但更廣泛的代碼依賴於該包含。

此問題的一個最小的例子如下:

test.h:

#include <lapacke.h> 
#include <boost/algorithm/string.hpp> 
#include <vector> 

TEST.CPP:

#include "test.h" 

void eig(std::vector<double> A, std::vector<double>& evecs, std::vector<double>&evals) { 
    int N = (int)A.size(); 

    if(N == 6) { 
     /// A is a 3x3 symmetric tensor 
     char jobz = 'V'; 
     char uplo = 'L'; 
     int N = 3; 
     int lda = 3; 
     int lwork = 15; 
     double work[lwork]; 
     double a[9] = { 
      A[0], A[3], A[4], 
      A[3], A[1], A[5], 
      A[4], A[5], A[2] 
     }; 

     LAPACKE_dsyev(LAPACK_ROW_MAJOR, jobz, uplo, N, &a[0], lda, &work[0]); 

     evals[0] = work[0]; 
     evals[1] = work[1]; 
     evals[2] = work[2]; 

     for(int i = 0; i < 9; i++) { 
      evecs[i] = a[i]; 
     } 
    } else { 
     fprintf(stderr, "ERROR: Unknown size of A in eig\n"); 
    } 
} 

int main(int argc, char** argv) { 


    return 0; 
} 

生成文件:

all: test.exe 

CC=g++ -std=c++11 

OPTS= -O3 -Wall 
LIBS= -lm -L/usr/lib/lapack -llapacke -llapack -lblas -lcblas 

test.exe: $(OBJS) test.cpp 
    $(CC) $(OBJS) $(DEFS) $(OPTS) test.cpp -o test.exe $(LIBS) 

clean: 
    rm -rf *.o 
+0

你能舉一個你看到的錯誤的例子嗎? –

回答

0

似乎這可能對包括敏感訂單。嘗試包括Boost庫第一,像這樣:

#include <boost/algorithm/string.hpp> 
#include <lapacke.h> 
#include <vector> 

對我來說,編譯和在這種配置跑(但如果lapacke包括第一次沒編譯)。