OpenCV 2.1 with Qt Creator on Windows
I have OpenCV 2.1 and Qt (Creator) installed on Windows.
Using the OpenCV C API, I can link, build and run applications in Qt using OpenCV.
However, when using the OpenCV C ++ API, I am having problems with linking.
This is probably due to C ++ ABI issues as I am using prebuilt binaries (built with MSVC-2008) for Windows and Qt Creator is using MinGW.
How do I configure CMake to recover OpenCV 2.1 so that the final one is .lib
Qt compatible?
Thanks!
a source to share
You need to make sure CMake finds the same MinGW that was used to compile Qt. If you downloaded the QtCreator package, you should have a mingw directory in your Qt installation directory. Make sure that this directory is in your path and that the correct version of MinGW will be used (for example, using the "which" command). Another alternative is to set the CMake variable CMAKE_CXX_COMPILER
to point to the correct executable in the mingw directory.
After that, all you have to do is run CMake in your OpenCV folder, reporting it with the generated MinGW makefiles, and then run make and you're done (hopefully)!
a source to share
The easiest way is to do one of these:
Option 1: . You are using the Qt SDK + mingw: go to the qt installation directory and open a Qt command prompt. This will add the mingw toolchain to your PATH. Add the cmake binary to your PATH: (example only, real directory may be different)
set PATH="C:\Program Files\CMake\bin;%PATH%
Option 2: . You are using a standalone installation of mingw: either go to the mingw installation directory and double-click the icon mingw32vars.bat
or similar. Command Prompt will appear and gcc is in PATH. If there is no such file, open a command cmd
prompt by typing Windows (Vista / 7) in the search bar or typing cmd
Run Command in the dialog box. Add mingw to PATH yourself (again, the example directory may be different on your system):
set PATH=C:\MinGW\bin;%PATH%
General second step:
Download the OpenCV sources, extract them somewhere and cd
into this directory using the command line. Make sure all tools can be found in PATH by running the following commands:
cmake --version
gcc -v
They have to report on some programs. If one command returns a command "Command not found" or similar, you have not configured your PATH correctly.
Compiling OpenCV: As I understand from your question, the OpenCV library you are trying to use is built using CMake. From the command line (which is now installed in the OpenCV source directory) do the following:
mkdir build
cd build
cmake .. -G"MinGW Makefiles"
mingw32-make
This should build the library in the "build" subdirectory. If there are any errors related to cmake or mingw32-make it will be a problem for OpenCV.
a source to share
You need to use the pre-built MinGW binaries which can be found at the qt ftp site .
a source to share