PDA

View Full Version : Undefined symbols for architecture x86_64 opencv



salman
13th January 2014, 18:02
I'm a newbie to qt and opencv
using qt creator 3 with qt 5 on os x 10.9.1 opencv 2.4.8
When i'm trying out with my first program, i get this error.
Any one please help me.
Thank you



#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;

int main()
{
//read image
Mat image = imread("img.jpg");
//create image window named "My image"
namedWindow("My Image", CV_WINDOW_AUTOSIZE);
//show the image on window
imshow("My image", image);
//wait key for 5000ms
waitKey(5000);
return 0;
}



test.pro


QT += core

QT -= gui

TARGET = test
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib \
-opencv_core.dylib \
-opencv_imgproc.dylib \
-opencv_highgui.dylib \
-opencv_features2d.dylib \
-opencv_calib3d.dylib
OTHER_FILES += img.jpg
SOURCES += main.cpp


Error generated


Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in main.o
"cv::namedWindow(std::string const&, int)", referenced from:
_main in main.o
"cv::Mat::deallocate()", referenced from:
_main in main.o
"cv::imread(std::string const&, int)", referenced from:
_main in main.o
"cv::imshow(std::string const&, cv::_InputArray const&)", referenced from:
_main in main.o
"cv::waitKey(int)", referenced from:
_main in main.o
"cv::fastFree(void*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
23:13:36: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test (kit: Desktop Qt 5.2.0 clang 64bit)
When executing step 'Make'

ChrisW67
13th January 2014, 20:30
You probably received earlier errors regarding invalid arguments to your linker. Lines 13 through 17 should read:


-lopencv_core \
-lopencv_imgproc \
...
(that is a lower case L)