c++ - QT creator添加opencv库报错: linker command failed with exit code 1

标签 c++ qt opencv qt-creator

我是 qt 的新手,我在我的 mac (os 10.8.5) 上安装了 qt creator,并想添加 openCv 库。我遵循了这个 youtube 教程的说明 ( http://www.youtube.com/watch?v=i9hYiMXLZRs )..不知道这是否重要。

我的 untitled5.pro 文件:

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 的一些代码。 通过运行这段代码,我得到两个错误:

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

我完全不知道该怎么做,花了好几个小时寻找答案。也许有人可以帮助我。你能告诉我错误信息是什么意思吗?我做错了什么?

最佳答案

检查您的图书馆名称。在您的 pro 文件中,第一个字母是 1(数字)而不是 l:

-libopencv_core \
-libopencv_imgproc \
-libopencv_features2d \
-libopencv_highgui

关于c++ - QT creator添加opencv库报错: linker command failed with exit code 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20067538/

相关文章:

c++ - DLL如何映射到当前程序的虚拟地址空间

c++ - 将 Opengl 模型加载到容器中并依次调用它们

c++ - 如何使用 SDL2 和 OpenGL 绘制三角形?

c++ - 将 int 转换为具有零填充(前导零)的 QString

c++ - boost 变体支持多少种数据类型?

Qt QCalendarWidget QSS 样式

c++ - 如何停止关闭QT Widget?

opencv - 如何将凸包点转换为图像中的实坐标

python - 如何使用python opencv找到图像中黑色物体的中心?

opencv - 使用vector <vector <KeyPoint >>进行OpenCV,SIFT计算