我編譯下面的C時,遇到了一個錯誤,不承認「*」的矩陣乘法++代碼:克++編譯使用犰狳庫
# include <iostream>
# include <armadillo>
using namespace arma;
using namespace std;
int main() {
mat A;
mat B;
mat C;
// Populating the matrices with random numbers
A.randu(3,3);
B.randu(3,3);
// Matrix multiplication
C = A * B;
cout << "Mutliplying matrices A and B:" << endl;
cout << "A * B = " << C << endl;
return 0;
}
這裏是我的錯誤使用g ++編譯時:
Undefined symbols for architecture x86_64: "_wrapper_dgemm_", referenced from:
void arma::blas::gemm<double>(char const*, char const*, int const*, > int const*, int const*, double const*, double const*, int const*, double > const*, int const*, double const*, double*, int const*) in >armadillo_playground-aa3649.o
"_wrapper_dgemv_", referenced from:
void arma::blas::gemv<double>(char const*, int const*, int const*, >double const*, double const*, int const*, double const*, int const*, >double const*, double*, int const*) in armadillo_playground-aa3649.o
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see >invocation)
當我替換矩陣乘法「*」與「+」,「%」,等等的代碼編譯沒有抱怨。
在此先感謝!
看起來'*'運算符的定義在源文件中,而且你沒有鏈接庫? –
哎呀,我不知道在圖書館連接。但是,現在我遇到了以下錯誤:dyld:Library not loaded:/usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib 引用自:/ usr/local/opt/arpack/libexec/lib/libarpack.2.dylib 原因是:image not found Trace/BPT陷阱:5 –
也許這有幫助嗎? http://stackoverflow.com/questions/24993752/os-x-framework-library-not-loaded-image-not-found –