在 macOS Sierra 上使用 Qt 的 Dlib C++ 库
Dlib C++ library with Qt on macOS Sierra
我在 macOS Sierra 上将 dlib c++ 库与 Qt 一起使用。我可以从终端编译所有示例,并使用 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)
看来新的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\
我在 macOS Sierra 上将 dlib c++ 库与 Qt 一起使用。我可以从终端编译所有示例,并使用 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)
看来新的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\