问题
I have used OpenCV 3.2.0 since a long time ago. Recently, I need to implement face detection with landmark detection so I decided to build the OpenCV again with extra OpenCV modules. However, it seems that OpenCV 3.2.0 is not compatible with the latest extra OpenCV modules so I have to build it with the latest OpenCV (which is 4.0.0)
The problem is, I'm in a Catch 22 situation.
1. If I use mingw 32bit 5.1.0 to build OpenCV (which is a compiler bundled with Qt), I have a following error
CMakeFiles\opencv_core.dir/objects.a: member CMakeFiles\opencv_core.dir/objects.a(vs_version.rc.obj) in archive is not an object
2. If I use mingw 64bit 8.1.0 to build OpenCV, it works fine. However there are two situations that give me an error.
2.1. If I use mingw 32bit 5.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.
D:\opencv-build\bin\libopencv_core400.dll:-1: error: file not recognized: File format not recognized
I suspect that this has something to do with 32-64bit problem. The compiler may expect 32bit libs, but the libs are 64bit format because the compiler used to build OpenCV was 64bit mingw.
file format pei-i386
file format pei-x86-64
The first one is the file format of the OpenCV 3.2.0 libs which I used in the past and worked fine with Qt. The second one is the file format of the OpenCV 4.0.0 libs newly built.
2.2 If I use mingw 64bit 8.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.
collect2.exe: error: ld returned 5 exit status
I suspect that this occurred because basically Qt is for 32-bit, not 64-bit.
What I want to do is that building OpenCV 4.0.0 so that somehow the file format of those OpenCV libs is pei-i386, not pei-x86-64. How can I achieve this?
来源:https://stackoverflow.com/questions/53263199/have-a-32-64bit-problem-with-opencv-and-qt