将OpenCV库添加到QT创建者并获取错误:链接器命令失败,退出代码1 [英] Adding opencv library to QT creator and getting error: linker command failed with exit code 1

查看:648
本文介绍了将OpenCV库添加到QT创建者并获取错误:链接器命令失败,退出代码1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的qt和我安装qt creator在我的mac(os 10.8.5),并想要添加openCv库。我按照此YouTube教程的说明( http://www.youtube.com/watch?v=

i'm new to qt and i installed the qt creator on my mac (os 10.8.5) and wanted to add the openCv library. I followed the instruction of this youtube tutorial (http://www.youtube.com/watch?v=i9hYiMXLZRs).. don't know if that matters.

我的untitled5.pro文件:

my untitled5.pro file:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled5
TEMPLATE = app

INCLUDEPATH = /usr/local/include

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

LIBS += -L/usr/local/lib \
     -1ibopencv_core \
     -1ibopencv_imgproc \
     -1ibopencv_features2d \
     -1ibopencv_highgui

FORMS    += mainwindow.ui

和main.cpp:

#include "mainwindow.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    IplImage* img = 0;
    img = cvLoadImage("/Users/path/to/image.jpg");
    cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow("Example1");

    return a.exec();
}

这只是一些代码来测试库opencv。
通过运行此代码,我得到两个错误:

It's just some code to test the library opencv. By running this code, i get two errors:

linker command failed with exit code 1 (use -v to see invocation)
[untitled5.app/Contents/MacOS/untitled5] Error 1

I绝对没有一个线索做什么,搜索答案几个小时。也许有人可以帮助我。

I absolute don't have a clue what to do, searching for answers for hours. Maybe someone can help me. Can you tell me what does the error message say and what could i've done wrong?

推荐答案

检查您的图书馆名称。您可以告诉我错误信息说明了什么,在您的pro文件中,第一个字母是 1 (number),而不是 l

Check your library names. In your pro file the first letter is 1 (number) instead of l:

-libopencv_core \
-libopencv_imgproc \
-libopencv_features2d \
-libopencv_highgui

这篇关于将OpenCV库添加到QT创建者并获取错误:链接器命令失败,退出代码1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆