c – 将opencv库添加到QT创建者并获取错误:链接器命令失败,退出代码为1
作者:互联网
我是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
我绝对不知道该做什么,几个小时都在寻找答案.也许有人可以帮助我.你能告诉我错误信息说的是什么,我做错了什么?
解决方法:
检查您的图书馆名称.在您的专业文件中,第一个字母是1(数字)而不是l:
-libopencv_core \
-libopencv_imgproc \
-libopencv_features2d \
-libopencv_highgui
标签:c,opencv,qt,qt-creator 来源: https://codeday.me/bug/20191002/1842748.html