未定义参考Armadillo的LAPACK包装器

时间:2013-06-12 09:32:46

标签: c++ linker lapack armadillo

我对使用犰狳有疑问。

我正在使用Ubuntu 12.10,以及Code :: Blocks中的gcc编译器。 我使用synaptic包管理器安装了LAPACK和BLAS。我还使用突触包管理器安装了一次Armadillo,一次是用CMake手动安装的。 CMake在进行犰狳编译的配置时找到了LAPACK和BLAS库。此外,我在“构建选项”中的Code :: Blocks中链接了BLAS和LAPACK库 - >“Linker”。

但是,每当我想构建我的项目时,都会收到错误消息:

 In function `void arma::lapack::getrf<double>(int*, int*, double*, int*, int*, int*)':|
/usr/include/armadillo_bits/lapack_wrapper.hpp|41|undefined reference to `wrapper_dgetrf_'|

这显然意味着犰狳无法找到LAPACK,但我做错了什么?

我还取消了armadillo_bits / config.hpp文件中各自的行,因此看起来像这样:

    #if !defined(ARMA_USE_LAPACK)
    //#define ARMA_USE_LAPACK
    //// Uncomment the above line if you have LAPACK or a high-speed replacement for LAPACK,
    //// such as Intel MKL, AMD ACML, or the Accelerate framework.
    //// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
    #endif

    #if !defined(ARMA_USE_BLAS)
    //#define ARMA_USE_BLAS
    //// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS,
    //// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate framework.
    //// BLAS is used for matrix multiplication.
    //// Without BLAS, matrix multiplication will still work, but might be slower.
    #endif

    /* #undef ARMA_USE_WRAPPER */
    //// Comment out the above line if you're getting linking errors when compiling your programs,
    //// or if you prefer to directly link with LAPACK and/or BLAS.
    //// You will then need to link your programs directly with -llapack -lblas instead of -larmadillo

当我尝试使用整数设置矩阵时,首先出现错误,所以

  Mat<int> element_nodes;

我很感激有用的答案。我在互联网上搜索了几个小时。另外,如果您需要更多源代码,请与我们联系。

3 个答案:

答案 0 :(得分:0)

看起来您安装了两个Armadillo副本,它们具有不同的配置。如有疑问,请将您的程序链接到:

g ++ prog.cpp -o prog -O2 -larmadillo -llapack -lblas

您可能还想查看Armadillo's FAQprevious Stackoverflow question

答案 1 :(得分:0)

我猜你还没有取消注释定义行!:

if!defined(ARMA_USE_LAPACK)

package password;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class password extends Thread {

    String[] l1 = {"w","e","r","s","f","x","c","v"};
    String[] l2 = {"u","o","j","k","l"};
    String[] l3 = {"a","s","d","y","c"};
    String[] l4 = {"i","o","p","k","é"};
    String[] l5 = {"w","e","r"};
    String[] l6 = {"q","w"};
    String[] l7 = {"e","r","t"};
    String[] l8 = {"e","t","d","f","g"};
    String[] l9 = {"z","u","i","h","k","n","m"};
    String[] l10 = {"q","e","a","s","d"};
    String[] l11 = {"q","w"};
    String[] l12 = {"r","t","z"};
    String[] l13 = {"i","o","p"};
    String[] l14 = {"h","j","k","n"};
    String[] l15 = {"w","a","s"};
    String[] l16 = {"o","è","l","é","a"};
    String[] l17 = {"q","w","e"};
    String[] l18 = {"t","z","u"};
    String[] l19 = {"r","t","z"};

    public password(int x, int y, int z) throws IOException{

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream("Z:/key"+"z"+".txt"), "utf-8"));

        new Thread(){
            int counter = 0, counter2 = 0;
            public void run() {}{
                for(int a = x; a<y; a++){
                    for(int b = 0; b<5; b++){
                        for(int c = 0; c<5; c++){
                            for(int d = 0; d<5; d++){
                                for(int e = 0; e<3; e++){
                                    for(int f = 0; f<2; f++){
                                        for(int g = 0; g<3; g++){
                                            for(int h = 0; h<5; h++){
                                                for(int i = 0; i<7; i++){
                                                    for(int j = 0; j<5; j++){
                                                        for(int k = 0; k<2; k++){
                                                            for(int l = 0; l<3; l++){
                                                                for(int m = 0; m<3; m++){
                                                                    for(int n = 0; n<4; n++){
                                                                        for(int o = 0; o<3; o++){
                                                                            for(int p = 0; p<5; p++){
                                                                                for(int q = 0; q<3; q++){
                                                                                    for(int r = 0; r<3; r++){
                                                                                        for(int s = 0; s<3; s++){
                                                                                            writer.write(new String(l1[a]+l2[b]+l3[c]+l4[d]+l5[e]+l6[f]+l7[g]+l8[h]+l9[i]+l10[j]+l11[k]+l12[l]+l13[m]+l14[n]+l15[o]+l16[p]+l17[q]+l18[r]+l19[s]));
                                                                                            writer.newLine();
                                                                                            counter++;
                                                                                            if(((counter%1000000) == 0) && counter!=0){
                                                                                                counter2++;
                                                                                                System.out.println("r0" + counter2);
                                                                                            }
                                                                                            Thread.yield();
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                writer.close();
            }
        };
    }
    public static void main(String[] args) throws IOException {
        password t0,t1,t2,t3;
        t0 = new password(0,1,0);
        t1 = new password(2,3,1);
        t2 = new password(4,5,2);
        t3 = new password(6,7,3);
        System.out.println("asd");

        long tiem = System.nanoTime();
        t0.start();
        t1.start();
        t2.start();
        t3.start();
        long anodertiem = System.nanoTime();

        System.out.println("Time taken: " + (anodertiem-tiem)/1000000);
    }

}

下面

答案 2 :(得分:0)

如果您使用了下载的armadillo软件包中的blas和lapack库文件,可能它们不起作用,因为在自述文件中,它说它们来自第三方,所以我从其他来源下载然后编译细