Solved How to use OpenCV inside QtCreator?
-
Hi,
Aren't you providing the path to a 64bit version of OpenCV while using a 32bit Qt ?
On a side note, you shouldn't link to .dll files but to .lib files.
-
Hei even i tried to follow the instructions from the same link which you attached. In the Cmake i am getting errors after i select c and c++ compilers and enter finish
Error in configuration process, project files may be invalid
Do you know what to do?
-
Damn, you're right. How did I not see that?
I built the libraries again using the right mingw compiler and now it seems to be working! Thanks a lot! :D
About the .lib files, there are none in the library. Or at least none I could find, only dll.
From what I've seen it's kind of normal for Cmake to throw some errors here and there. If you try hitting the configure botton again what happens?
-
You're welcome !
Late night debugging can have that kind of effect ;)
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)
-
@Beriol its the same error again and again
can you write in brief what all you have done, it will be much useful for me and others who are trying it for first time. -
I followed exactly the guide I posted in the first post. For me the hard part was actually linking the libraries, not building them.
Are you sure you selected the right compilers? The path should be something like:
C:\YourPathToQT\Qt\Tools\mingw48_32\bin\gcc.exe <-- for C
C:\YourPathToQT\Qt\Tools\mingw48_32\bin\g++.exe <-- for C++In my case inside the "Tools" folder there is also a folder called MinGW which also contain the bin with the compilers, but do NOT use that (which was my mistake).
Besides this, did you add the path to CMake to your system PATH variable and restarted the computer?
-
@Beriol
I downloaded and extracted openCV. Later installed Qt. Added the directories
C:\Qt\5.5\mingw492_32\bin
C:\opencv\build\x86\vc12\bin
to the path in Environment variables.Later downloaded CMake and installed it and added its path
C:\CMake\bin
Created an empty folder opencv-mingw in C-DriveRebooted Laptop
In CMake i selected
the sourcecode Directory asC:\Qt\Tools\mingw492_32\bin
(also tried withC:\Qt\5.5\mingw492_32\bin
)
Buid the binary inC:/opencv-mingw
and hit configure buttonSelected MinGW Makefiles from dropdown menu. Then it asked to specify native compilers
SpecifiedC:/Qt/Tools/mingw491_32/bin/gcc.exe
for C
specifiedC:/Qt/Tools/mingw491_32/bin/g++.exe
for C++
and hit finishIT GAVE ME ERROR
Error in configuration process, Project files may be invalid -
The "sourcecode directory" inside CMake should point to the folder that contains the source code for OpenCV, not the folder that contains compiler executables like the one you're using!
So, you should put the path to the folder where you extracted the OpenCV stuff. Something like "C:/opencv/sources". That's why you're getting the error at start, there are no source files to configure :)
-
@Beriol Oh yes, thanks for the that
It was my silly mistake... It is working and I have generated the compilers in Cmake.But in Command prompt after entering
mingw32–make
,
I was left with errors at 31%, I referred the comments in the link and uncheckedWITH_IPP
and regenerated in Cmake.But this time I was a getting errors at 37% in Command prompt.
makefile: 148: recipe for target 'all' failed mingw32-make: ***[all] Error 2
Do you know anything about this?
-
It happened to me too, but I don't remember what exactly fixxed that problem.
Try this: in CMake tick the option "Advanced" (it's on the right after the search bar), and search for CMAKE__MAKE_PROGRAM; make sure that it points to the mingw32-make.exe inside you Qt folder "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe". I remember that in my case it wasn't set right and I used to get errors because of that.
Besides this I'm not sure what else you could do... Did you check "WITH_QT"?
Also, try unchecking "WITH_CUDA". I remember reading somewhere that it might give problems, but I actually don't remember if it gave me any while building.