I have OpenCV 2.1 and Qt (Creator) installed on Windows.
Using the OpenCV C API I can link, build and run apps in Qt using OpenCV.
However, the when using the OpenCV C++ API, I am getting linking problems.
This is probably due to C++ ABI problems, since I'm using the pre-built binaries (built with MSVC-2008) for Windows and Qt Creator uses MinGW.
How do I configure CMake to rebuild OpenCV 2.1 so that the resulting .lib
s are compatible with Qt?
Thanks!
相关问题
- Sorting 3 numbers without branching [closed]
- How to get the background from multiple images by
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
You need to use the pre-built MinGW binaries which can be found on the qt ftp site.
The simplest way is to do one of these:
Option 1: You use the Qt SDK+mingw: go to the qt install directory and open a Qt command prompt. This will add you mingw toolchain to your PATH. Add the cmake binary to your PATH: (only an example, real directory might differ)
Option 2: You use a standalone installation of mingw: Either go to the mingw install directory and doubleclick the
mingw32vars.bat
or similar. A command prompt should pop up and gcc should be in PATH. If there is no such file, open a command prompt: typecmd
in the windows search bar (Vista/7) or typecmd
in the Run command dialog. Add mingw to PATH yourself (again, example directory, might differ on your system):Common second step: Download the OpenCV sources, extract them somewhere and
cd
to that directory with your command prompt. Ensure all tools can be found in PATH by running these commands:These should report some info on the programs. If one command returns "Command not found" or similar, you haven't set up your PATH correctly.
Compiling OpenCV: I understand from your question that the OpenCV library you're trying to use is built using CMake. From your command prompt (which now is set to the OpenCV source directory), do the following:
This should build the library in the "build" subdirectory. If there are any errors related to cmake or mingw32-make, that would be problems for OpenCV.
This post shows step by step how to install Qt on Windows and how to compile OpenCV 2.3.1 with MingW and integrate it with Qt-Creator.
It provides screenshots and videos for orientation.
You need to make sure that CMake will find the same MinGW that was used to compile Qt. If you downloaded the QtCreator bundle, you should have a mingw directory in 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 command "which"). Another alternative is to configure the CMake variable
CMAKE_CXX_COMPILER
so that it points to the correct executable in the mingw directory.After that, all you need to do is run CMake in your OpenCV folder, telling it to generated MinGW makefiles, then run make and you're done (hopefully)!