简体   繁体   中英

Undefined Variable in Qt Creator C++ using OpenCV

I'm facing problem in my qt creator, here is the issue that shown by Qt Creator:

D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\Sobel\\main.cpp:39: error: undefined reference to cv::imread(cv::String const&, int)
D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\Sobel\\main.cpp:60: error: undefined reference to cv::namedWindow(cv::String const&, int)
D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\Sobel\\main.cpp:61: error: undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)
D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\Sobel\\main.cpp:64: error: undefined reference to cv::namedWindow(cv::String const&, int)
D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\Sobel\\main.cpp:65: error: undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)
D:\\Kuliah\\Semester 5\\IF431316 PECI\\Qt Project File\\build-Sobel-Desktop-Debug\\debug\\main.o:-1: In function `ZN2cv6StringC1EPKc': collect2.exe:-1: error: error: ld returned 1 exit status

This is my .pro file that contain library, I've trying add some libraries as suggested by many members, but nothing happen at all, it's getting worse

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

INCLUDEPATH += C:\\opencv\\build\\include \
INCLUDEPATH += C:\\opencv\\sources\\include \

LIBS += -LC:\\opencv\\sources\Built_with_Qt\\debug\\lib \
  -lopencv_calib3d231d \
  -lopencv_contrib231d \
  -lopencv_core231d \
  -lopencv_features2d231d \
  -lopencv_flann231d \
  -lopencv_gpu231d \
  -lopencv_highgui231d \
  -lopencv_imgproc231d \
  -lopencv_legacy231d \
  -lopencv_ml231d \
  -lopencv_objdetect231d \
  -lopencv_ts231d \
  -lopencv_video231d

Wrong direction of slashes. Qt is using Linux style directory separators even if it is windows platform.

INCLUDEPATH += C:/opencv/build/include \
INCLUDEPATH += C:/opencv/sources/include \

LIBS += -LC:/opencv/sources/Built_with_Qt/debug/lib \
  -lopencv_calib3d231d \
  -lopencv_contrib231d \
  -lopencv_core231d \
  -lopencv_features2d231d \
  -lopencv_flann231d \
  -lopencv_gpu231d \
  -lopencv_highgui231d \
  -lopencv_imgproc231d \
  -lopencv_legacy231d \
  -lopencv_ml231d \
  -lopencv_objdetect231d \
  -lopencv_ts231d \
  -lopencv_video231d

Another problem I can see is that you are using namedWindow . If you have a Qt then you should not use it since Qt provide on windows which are much more handy.

Apparently you are using some custom build of OpenCV. Are you sure that it wasn't configured in such way the unneeded for Qt functions were deactivated?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM