我在macOS Sierra上使用带有Qt的dlib c ++库。我可以用终端和Qt的一些例子编译所有的例子。但是,编译一些示例(例如使用Qt进行优化)会抛出链接器错误:
Undefined symbols for architecture x86_64:
"_cblas_daxpy", referenced from:
dlib::blas_bindings::cblas_axpy(int, double, double const*, int, double*, int) in main.o
"_cblas_ddot", referenced from:
dlib::blas_bindings::cblas_dot(int, double const*, int, double const*, int) in main.o
"_cblas_dgemv", referenced from:
dlib::blas_bindings::cblas_gemv(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, double, double const*, int, double const*, int, double, double*, int) in main.o
"_cblas_dger", referenced from:
dlib::blas_bindings::cblas_ger(dlib::blas_bindings::CBLAS_ORDER, int, int, double, double const*, int, double const*, int, double*, int) in main.o
"_cblas_dscal", referenced from:
dlib::blas_bindings::cblas_scal(int, double, double*) in main.o
"_cblas_dtrsm", referenced from:
dlib::blas_bindings::cblas_trsm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_SIDE, dlib::blas_bindings::CBLAS_UPLO, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_DIAG, int, int, double, double const*, int, double*, int) in main.o
"_dgetrf_", referenced from:
dlib::lapack::binding::getrf(int, int, double*, int, int*) in main.o
"_dpotrf_", referenced from:
dlib::lapack::binding::potrf(char, int, double*, int) in main.o
"_dsyevr_", referenced from:
dlib::lapack::binding::syevr(char, char, char, int, double*, int, double, double, int, int, double, int*, double*, double*, int, int*, double*, int, int*, int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我还包含在.pro文件中: LIBS + = -L / usr / local / lib \ -ldlib \
安装LAPACK,BLAS和CBLAS并在.pro中包含-lblas和-llapack后,除了上述错误外,我还收到了此错误:
warning: object file (/usr/local/lib/liblapack.a(iladlr.o)) was built for newer OSX version (10.12) than being linked (10.8)
Undefined symbols for architecture x86_64:
"__gfortran_concat_string", referenced from:
_dormtr_ in liblapack.a(dormtr.o)
_dormql_ in liblapack.a(dormql.o)
_dormqr_ in liblapack.a(dormqr.o)
"__gfortran_st_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_st_write_done", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_stop_string", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_string_len_trim", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_transfer_character_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
"__gfortran_transfer_integer_write", referenced from:
_xerbla_ in libblas.a(xerbla.o)
答案 0 :(得分:2)
似乎新的macOS已经有了LAPACK。您只需要在.pro文件中包含-lcblas和-lclapack。您可以在/ usr / lib或/ usr / local / lib中找到它们。
如果在/ usr / lib中:
LIBS += -L/usr/lib\
-lcblas\
-lclapack\
-L/usr/local/lib\
-ldlib\
如果在/ usr / local / lib
中LIBS += -L/usr/local/lib\
-lcblas\
-lclapack\
-ldlib\