PDA

View Full Version : Opencv with static qt



Sashabn
22nd June 2015, 12:03
Hi everyone,i am a newbie. I was start learning c++ 4 mounts ago, and 2 mounts ago i found qt. Now i want to learn how to build static apps with custom libs and i stacks here.That custom library is opencv, and i trying to build static application with opencv.
In cmake,when i configure opencv for building , i was set BUILD_SHARED_LIBS=off and after that ,when i build opencv, i include these opencv static libs in my project:

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled13
TEMPLATE = app
CONFIG += static

SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

INCLUDEPATH +=C:\opencv\myocv\install\include

LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libIlmImf.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ liblibjasper.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ liblibjpeg.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ liblibpng.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ liblibtiff.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_calib3d2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_contrib2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_core2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_features2d2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_flann2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_gpu2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_highgui2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_imgproc2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_legacy2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_ml2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_nonfree2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_objdetect2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_ocl2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_photo2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_stitching2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_superres2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_ts2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_video2411.a
LIBS+=C:\opencv\myocv\install\x64\mingw\staticlib\ libopencv_videostab2411.a


And when i try to compile application i got this errors:

grfmt_tiff.cpp:-1: error: undefined reference to `TIFFClose'
grfmt_tiff.cpp:-1: error: undefined reference to `TIFFOpen'
:-1: error: C:\opencv\myocv\install\x64\mingw\staticlib\libope ncv_highgui2411.a(grfmt_tiff.cpp.obj): bad reloc address 0x2c in section `.text$_ZN2cv11TiffDecoder10readHeaderEv'
:-1: error: final link failed: Invalid operation
collect2.exe:-1: error: error: ld returned 1 exit status


Does someone have experience with this problem.
Thanks a lot.

jefftee
24th June 2015, 06:26
Are the 2nd through 5th static library names correct? You have liblib prefixes and everything else is prefixed with lib.