openCV mingw+cmake编译的bug/error笔记
来源:互联网 发布:通知栏网络图标不见了 编辑:程序博客网 时间:2024/05/16 17:20
使用cmake生成openCV3.1.0 makefile文件,在mingw下编译openCV。
1.openCV的build和源码目录,不能存在中文路径,否则报以下错误:
mingw32-make[2]: *** No rule to make target 'J://opencv-3.1.0/3rdparty/zlib/adler32.c', needed by '3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.obj'. Stop.
CMakeFiles\Makefile2:252: recipe for target '3rdparty/zlib/CMakeFiles/zlib.dir/all' failed
mingw32-make[1]: *** [3rdparty/zlib/CMakeFiles/zlib.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
2.使用cmake发布makefile的时候,请禁用BUILD_TESTS,否则将在42%左右报以下错误:
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
critical_section_(new CRITICAL_SECTION) {
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8879:33: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
critical_section_ = new CRITICAL_SECTION;
^~~~~~~~~~~~~~~~
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
modules\ts\CMakeFiles\opencv_ts.dir\build.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFiles\Makefile2:5379: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
3.opencv3.2.0 mingw编译,在54%左右报以下错误:
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
critical_section_(new CRITICAL_SECTION) {
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8879:33: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
critical_section_ = new CRITICAL_SECTION;
^~~~~~~~~~~~~~~~
G:\Coding\MinGW\msys\1.0\home\Administrator\opencv-3.2.0\modules\ts\src\ts_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
modules\ts\CMakeFiles\opencv_ts.dir\build.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[3]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFiles\Makefile2:3919: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make[1]: *** [all] Error 2
参考国外给出的修改.h文件,增加mingw目标的定义:
https://stackoverflow.com/questions/41930349/opencv-installation-error-while-mingw32-make-on-windows
Edit "ts_gtest.h" which is inside "opencv\sources\modules\ts\include\opencv2\ts\"Replace this line (probably line 723) // assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. // This assumption is verified by // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. struct _RTL_CRITICAL_SECTION;with #if GTEST_OS_WINDOWS_MINGW // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two // separate (equivalent) structs, instead of using typedef typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; #else // Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. // This assumption is verified by // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endifReplace this line (probably on line 3060 before your edit - line number would have changed as you modified first part) _RTL_CRITICAL_SECTION* critical_section_;with GTEST_CRITICAL_SECTION* critical_section_;These two changes should fix your above error.
4.Ubuntu14下编译FFmpeg外加库与filter报错:
/usr/bin/ld: /usr/local/lib//libTransform360.a(VideoFrameTransformHandler.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib//libTransform360.a: 无法添加符号: 错误的值
上述错误提示和原来的没有添加“-fPIC”生成的“*.o”文件生成动态库出现的错误相同,而且也给给出了解决方法,静态库的生成重新使用“-fPIC”进行编译。
[billing_dx@bmcs1]:/account/work/ymm/test/library/nest_call>g++ -fPIC -c showcoor.cpp [billing_dx@bmcs1]:/account/work/ymm/test/library/nest_call>ar -cr libshowcoor.a showcoor.o [billing_dx@bmcs1]:/account/work/ymm/test/library/nest_call>g++ -fPIC -c showpoint.cpp [billing_dx@bmcs1]:/account/work/ymm/test/library/nest_call>g++ -shared -fPIC -o libshowpoint.so showpoint.o -L./ -lshowcoor [billing_dx@bmcs1]:/account/work/ymm/test/library/nest_call>ls *.so libshowpoint.so
- openCV mingw+cmake编译的bug/error笔记
- opencv eclipse cmake mingw 编译 配置
- CMake+MinGW编译OpenCV-2.4.7
- CMake+mingw-w64编译opencv-3.3.1
- MingW Cmake bulid OpenCV
- 使用CMake + MinGW + Eclipse 开发OpenCV --编译,使用以及可能遇到的问题详解
- OpenCV使用CMake和MinGW的编译安装及其在Qt配置运行
- cmake编译 itk,vtk, igstk 的MinGW版本
- 使用Qt带的MinGW+cmake编译opencv3.2
- mingw 编译opencv
- OpenCV学习笔记(四):CMake 编译 OpenCV源码 on Windows
- cmake重编译opencv遇到的问题
- CMake编译opencv各选项的含义
- build opencv by mingw & cmake on windows
- codeblocks+OpenCV+cmake+MinGW环境搭建
- cmake编译opencv程序
- CMake OpenCV源代码编译
- cmake 编译OpenCV程序
- Common application properties
- SDK location not found. Define location with sdk.dir in the local
- java反射方法详解
- html之使用inline-block,div错位处理
- JDBC之处理可滚动的结果集和可更新的结果集
- openCV mingw+cmake编译的bug/error笔记
- 省级期刊发表要求
- python画图
- caffe-fcn-solver.py
- CDH中 Apache Kylin使用spark引擎构建Cube
- group_concat()函数运用
- java常用设计模式小结
- 原来钱还可以这样赚!0门槛,0难度,免费日加几百粉
- js刷新本showModalDialog窗口