Ask Your Question
0

Install openCV on OSX using it with QT5.2 // unknown variable error

asked 2014-02-05 03:43:43 -0500

Ben_Pflaenz gravatar image

updated 2014-02-05 13:13:54 -0500

Hello

I am new to openCV and I would like to install openCV and use it with QT. I used macports to install it and i set the path in the terminal.

What I did was;

I installed macports I typed in the terminal

export PATH=$PATH:/opt/local/bin
source .profile
sudo port -v selfupdate 
sudo port install opencv

restart

Then i tested if its 64 bit built:

/opt/local/lib/libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Thats all...

Now i try to compile a Helloworld but i get unknown variable error. Looks like something with the linker gone wrong or i included the wrong libs? I searched google and I found some hints but nothing helped yet. Maybe someone got a suggestion? Thank you very much for your time and answer!

My settings:

#-------------------------------------------------
#
# Project created by QtCreator 2014-02-04T22:10:07
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = opencvTest
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

INCLUDEPATH += /opt/local/include

LIBS += -L/opt/local/lib
LIBS += -lopencv_core
        -lopencv_highgui





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

using namespace std ;
using namespace cv ;

int main()
{
    Mat img ;

    img = imread("unknown.jpg") ;

    return 0;
}

Error message

10:39:10: Running steps for project opencvTest...
10:39:10: Configuration unchanged, skipping qmake step.
10:39:10: Starting: "/usr/bin/make" 
/Users/Ben/Qt/5.2.0/clang_64/bin/qmake -spec macx-g++ CONFIG+=debug CONFIG+=x86 CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../opencvTest/opencvTest.pro
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -o opencvTest main.o   -F/Users/Ben/Qt/5.2.0/clang_64/lib -L/opt/local/lib -lopencv_core -framework QtCore 
Undefined symbols for architecture x86_64:
  "cv::imread(std::string const&, int)", 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: *** [opencvTest] Error 1
10:39:10: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project opencvTest (kit: Unnamed)
When executing step 'Make'
10:39:10: Elapsed time: 00:00.
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-02-16 23:24:03 -0500

Hi,

I have the same problem.

I tried use macports and manual compiling, but both problem.

Do you solve it?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-02-05 03:43:43 -0500

Seen: 583 times

Last updated: Feb 16 '14