I have no problem linking the dynamic opencv libraries, but I want to use static libraries instead, so I rebuilt OpenCV 2.3 with the "build shared libraries" option unchecked. I put the following on my .pro file
LIBS += "C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_calib3d231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_contrib231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_core231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_features2d231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_flann231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_gpu231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_imgproc231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_legacy231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_ml231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_objdetect231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_ts231.a" \
"C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_video231.a"
INCLUDEPATH += "C:\Program Files\openCV_static\opencv\build\install\include"
INCLUDEPATH += "C:\Program Files\openCV_static\opencv\build\install\include\opencv"
This is very similar to what I had before when I was using the dynamic libraries, except the .a files actually ended in .dll .a, and I put the dll's (not the dll.a files) in the qt program's output directory (so the program could find them and run). Now the whole point is that I don't need those dlls, so they're no longer in my program's output directory (actually they didn't build with OpenCV). But I get these errors when I try to build my program:
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x13): undefined reference to `AVIStreamRelease#4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x25): undefined reference to `AVIStreamRelease#4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN17CvVideoWriter_VFW5closeEv+0x37): undefined reference to `AVIFileRelease#4'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureCAM_VFW4openEi+0x6c): undefined reference to `capGetDriverDescriptionA#20'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureCAM_VFW4openEi+0xb7): undefined reference to `capCreateCaptureWindowA#32'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(cap_vfw.obj):cap_vfw.cpp:(.text$_ZN16CvCaptureAVI_VFW9grabFrameEv+0x29): undefined reference to `AVIStreamGetFrame#8'
.
.
.
.
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(grfmt_jpeg2000.obj):grfmt_jpeg2000.cpp:(.text$_ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x17b): undefined reference to `jas_stream_close'
C:\Program Files\openCV_static\opencv\build\install\lib\libopencv_highgui231.a(grfmt_jpeg2000.obj):grfmt_jpeg2000.cpp:(.text.startup._GLOBAL__sub_I_C__Program_Files_openCV_static_opencv_modules_highgui_src_grfmt_jpeg2000.cpp+0x4): undefined reference to `jas_init'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [release\trusion.exe] Error 1
mingw32-make.exe: *** [release] Error 2
23:21:10: The process "C:\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building project trusion (target: Desktop)
When executing build step 'Make'
I am using MinGW. Compiling the project with the same toolchain used to build opencv. Worked with dynamic libs, as mentioned above. Does not work with static libs.
It seems you're missing Jasper dependency.
OpenCV on Windows uses pre-built libjasper library (lib/libjasper*), try adding them to LIBS
For the 'undefined reference to AVIStreamRelease#4'error, try linking against vfw32.lib or MSVFW32.dll
Related
I got opencv_contrib pack files from github https://github.com/Itseez/opencv_contrib
and built it successfully as the README says ,
$ cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
then I typed make install to generate .so files (Did I misunderstand this command here?) .
But when I use qt to compile this example docs.opencv.org/master/db/d56/tutorial_capture_graycode_pattern.html#gsc.tab=0
it comes error like
undefined reference to `cv::structured_light::GrayCodePattern::Params::Params()'
what should I do?
the following things I've added it in .pro
INCLUDEPATH += /home/tau/opencv/opencv-3.1.0/include /home/tau/opencv/opencv_contrib/modules/structured_light/include
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_video -lopencv_videoio-lopencv_structured_light
When I try to generate a makefile with qmake in a sub-directory, the makefile is generated in a wrong directory.
Here is my QmakeTest.pro, the main.cpp is a simple hello world code :
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
When I run qmake:
qmake -makefile -o build/makefile
qmake -makefile -o build/makefile
The first time, the folder build/ is created and the makefile is created in the right directory, the second time(and each time if build/ already exist), the makefile is generated in the folder build/build/ (a subfolder build inside the first one).
Why does qmake create a second subdirectory if the subdirectory build/ already exist ?
For info: qmake --version
QMake version 3.0
Using Qt version 5.3.0 in /usr/lib/x86_64-linux-gnu
Edit: The bug seems to be fixed with the QMake provided with qt 5.4.0
You can use
QMAKE_MAKEFILE += build/makefile
in your project file to create the makefile
I am trying to compile an example from a library.
I have Qt installed but I think I have to link it and I don't know how.
This is the error:
g++ face_recognition.cpp -o test
In file included from face_recognition.cpp:29:0:
/usr/local/include/openbr/openbr_plugin.h:22:23: fatal error: QDataStream: No such file or directory
#include <QDataStream>
^
compilation terminated.
You can't compile a Qt application directly with g++ because the application must first go through Qt's moc compiler.
If you want to build a Qt application from the cmd-line, make sure you define an appropriate .pro file that specifies the Qt modules and other 3rd party headers/libraries you want might to use. For instance:
QT += core widgets
SOURCES += \
main.cpp
Then invoke qmake on the command line in the same directory as the .pro file to build the appropriate Makefiles, and finally execute make to build the app.
so i m trying to setup a movable folder for a Qt project where I 'll have this structure and everything will be dependent ONLY with that content..
project\
script.dat "script to invoke qmake with just a click"
qmake.exe
moc.exe
mkspec\ "win32-msvc2010" copy
common\ "necessary by qmake" copy
project.pro
sources\
main.cpp
etc...
headers\
etc...
depedencies\
Qt\
include\
lib\
dll\
e.g.Boost\
include\
lib\
dll\
as can be seen i want a decent folder structure where the script will append the path to the dlls and set QMAKESPEC etc with respect to the %cd% (PWD) directory of the .pro file...
However the problem arises when i invoke qmake.exe
C:\Users\ardit\Desktop\test>qmake -v
QMake version 3.0
Using Qt version 5.2.1 in C:\build-essential\Qt\5.2.1\msvc2010_opengl\lib
and after that
qmake -tp vc
creates a project that has everything linked to my Qt installation and NOT the folder specified in the pro
visual studio additional include directories:
"include";".";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtGui";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtCore";"debug";........\build-essential\Qt\5.2.1\msvc2010_opengl\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)
I havent put the Qt installation in the Path, but still the qmake.exe knows it somewhow (registry perhaps?)...
example .pro file where include\ has copy of Qt5\include\ , lib\ and dll\ as well
TARGET= test
SOURCES += main.cpp\
mainwindow.cpp \
glwindow.cpp
HEADERS += mainwindow.h \
glwindow.h
INCLUDEPATH=$${PWD}\include $$PWD
DEPENDPATH=$${PWD}\include $$PWD
LIBPATH=$${PWD}\lib
LIBS+=-L$$LIBPATH -lQt5Core -lQt5Gui -lQt5Widgets
Sidenote: I m new here so plz dont bash me...
any help appreciated...
I am working in embedded system domain and i was trying to cross-compile a QT- program for the ARMv7 platform.
I am using the following cross-compiler ---
" angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar "
I had all the shared libraries required by the program inside /usr/lib folder ( I am using Angstrom-linux in my target platform ) so i guess there is no need to give path of my shared libraries to the loader. But still it is showing some error that some of the shared libraries require GLIBC_2.9 ( "error : GLIBC_2.9 not found" ). I don't have a gcc compiler for my target platform so i am cross-compiling my programs, is that the reason ???????????
This is what you should do in a qmake based project for cross-compiling in your scenario:
qmake -r -spec linux-arm-gnueabi-g++
and the qmake project file should contain this:
LIBS += /usr/local/.../lib # path to your embedded target libraries
Note that you may also need to set up the following variable, too, for having the includes right:
INCLUDEPATH += /usr/local/.../include # path to your embedded target headers