lapacke与boost冲突?

时间:2016-04-23 21:33:23

标签: c++ boost

如果我不包含<lapacke.h>,我会收到以下错误:

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

1 个答案:

答案 0 :(得分:0)

似乎这可能对包含订单很敏感。首先尝试包括boost库:

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

对我来说,它在这个配置中编译并运行(但如果首先包含lapacke,则无法编译)。