转 opencv2.framework运行报错

我碰到的错误信息是如下信息:

Undefined symbols for architecture armv7s:

"_jpeg_free_small", referenced from:

_free_pool in opencv2(jmemmgr.o)

_self_destruct in opencv2(jmemmgr.o)

"_jpeg_mem_available", referenced from:

_realize_virt_arrays in opencv2(jmemmgr.o)

"_jpeg_free_large", referenced from:

_free_pool in opencv2(jmemmgr.o)

"_jpeg_open_backing_store", referenced from:

_realize_virt_arrays in opencv2(jmemmgr.o)

"_jpeg_get_large", referenced from:

_alloc_large in opencv2(jmemmgr.o)

_realize_virt_arrays in opencv2(jmemmgr.o)

"_jpeg_mem_term", referenced from:

_jinit_memory_mgr in opencv2(jmemmgr.o)

_self_destruct in opencv2(jmemmgr.o)

"_jpeg_mem_init", referenced from:

_jinit_memory_mdgr in opencv2(jmemmgr.o)

"_jpeg_get_small", referenced from:

_jinit_memory_mgr in opencv2(jmemmgr.o)

_alloc_small in opencv2(jmemmgr.o)

ld: symbol(s) not found for architecture armv7s

clang: error: linker command failed with exit code 1 (use -v to see invocation)

这个报错信息是因为无法连接libjpeg.a这个library

解决方法如下:

1.去 http://sourceforge.net/projects/libjpeg-turbo/files/1.4.0/ 这里下载libjpeg-turbo-1.5.1.dmg (8.4 MB)文件

2.安装下载的文件,安装后可以在这个地址找到它:/opt/libjpeg-turbo-lib

3.打开终端,输入lipo -info /opt/libjpeg-turbo/lib/libjpeg.a(注意空格)会得到这样的结果* Architectures in the fat file: /opt/libjpeg-turbo/lib/libturbojpeg.a are: i386 x86_64 armv6 armv7 armv7s arm64*

4.打开finder找到/opt/libjpeg-turbo/lib and copy libjpeg.a这个.a文件,拖到工程中

5.在Linked frameworks and libraries中也添加该文件,运行,问题解决

问题 2

报错信息:

Undefined symbols for architecture armv7: "std::__1::basic_string, std::__1::allocator >::basic_string(std::__1::basic_string, std::__1::allocator > const&)", referenced from: cv::Exception::Exception(int, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, int) in opencv2(system.o) cv::Exception::Exception(cv::Exception const&) in opencv2(system.o) "std::__1::basic_string, std::__1::allocator >::~basic_string()", referenced from: cv::Mat::create(int, int const*, int) in opencv2(matrix.o) __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&) in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const*) in opencv2(matrix.o) cv::Mat::diag(int) const in opencv2(matrix.o) cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o) cv::Mat::reserve(unsigned long) in opencv2(matrix.o) ... "std::__1::basic_string, std::__1::allocator >::__init(char const*, unsigned long)", referenced from: cv::Mat::create(int, int const*, int) in opencv2(matrix.o) __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&) in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const*) in opencv2(matrix.o) cv::Mat::diag(int) const in opencv2(matrix.o) cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o) cv::Mat::reserve(unsigned long) in opencv2(matrix.o) ... "std::_1::_vector_base_common::__throw_length_error() const", referenced from: std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) ... "std::__1::basic_string, std::__1::allocator >::operator=(std::__1::basic_string, std::__1::allocator > const&)", referenced from: cv::Exception::formatMessage() in opencv2(system.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决方法:build Setting中C++Standard Library设置为lib++(LLVM C++ standard library with C++11 support)

你可能感兴趣的:(转 opencv2.framework运行报错)