使用qmake在Ubuntu中一起编译QT和OpenCV

时间:2014-01-24 22:23:29

标签: c++ qt opencv ubuntu

我正在编写一个OpenCV应用程序和一个QT GUI,我正在编写一些问题。 一些可能有用的背景信息;操作系统是Ubuntu 13.10,输出" qmake --version"是:QMake 3.0版在/ usr / lib / x86_64-linux-gnu中使用Qt版本5.0.2

问题始于一行代码的出现,即" Mat cvImage"我声明一个Mat对象。我编译的方式是第一个" qmake -project"然后" qmake"然后我进入我的.pro文件并添加" QT + =小部件"然后我键入" make",当我这样做时,我收到错误

/usr/lib/x86_64-linux-gnu/qt5/bin/qmake -o Makefile gui2.pro
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB    -DQT_CORE_LIB -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -    I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o main.o     main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:55:2: error: ‘Mat’ was not declared in this scope
  Mat cvImage;
  ^
main.cpp:55:2: note: suggested alternative:   
In file included from main.cpp:20:0:
/usr/local/include/opencv2/core/core.hpp:1683:18: note:   ‘cv::Mat’
 class CV_EXPORTS Mat
                  ^
main.cpp:55:6: error: expected ‘;’ before ‘cvImage’
  Mat cvImage;
  ^
make: *** [main.o] Error 1

说实话,我不知道"在main.cpp中包含的文件:20:0:/usr/local/include/opencv2/core/core.hpp:1683:10注意:&# 39; cv :: Mat' "手段。我包括所有适当的OpenCV库,我不知道如何解释该错误输出行。以下是我的代码

/*****************C++ Libraries******************/
#include <iostream>

/****************User Defined*******************/
#include "function.h"
#include "function.cpp"

/****************Libraries Needed for QT********/
#include <QObject>
#include <QApplication>
#include <QWidget>
#include <QGridLayout>
#include <QSpinBox>
#include <QLabel>
#include <QGraphicsScene>
#include<QGraphicsView>
#include <QGraphicsPixmapItem>

/************Libraries Needed For OpenCV*******/
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;

int main(int argc, char ** argv){
    QApplication a(argc, argv);
/** some code that runs a gui ***/


    Mat cvImage; // This is where the problem starts
    window.show();
    return a.exec();
}

我也查看了我的Makefile,我没有看到OpenCV库的任何路径或任何东西,所以我尝试添加它们,它引起了更多的问题。

这是自动生成的Makefile(通过qmake命令)

#############################################################################
# Makefile for building: gui2
# Generated by qmake (3.0) (Qt 5.0.2) on: Mon Jan 27 12:24:52 2014
# Project:  gui2.pro
# Template: app
# Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -o Makefile gui2.pro
#############################################################################

MAKEFILE      = Makefile

####### Compiler, tools and options

CC            = gcc
CXX           = g++
DEFINES       = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
CFLAGS        = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE $(DEFINES)
CXXFLAGS      = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE $(DEFINES)
INCPATH       = -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I.
LINK          = g++
LFLAGS        = -m64 -Wl,-O1
LIBS          = $(SUBLIBS) -L/usr/X11R6/lib64 -lQt5Widgets -L/usr/lib/x86_64-linux-gnu -lQt5Gui -lQt5Core -lGL -lpthread 
AR            = ar cqs
RANLIB        = 
QMAKE         = /usr/lib/x86_64-linux-gnu/qt5/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = cp -f
COPY_DIR      = cp -f -R
STRIP         = strip
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = main.cpp moc_function.cpp
OBJECTS       = main.o \
        moc_function.o
DIST          = /usr/share/qt5/mkspecs/features/spec_pre.prf \
        /usr/share/qt5/mkspecs/common/shell-unix.conf \
        /usr/share/qt5/mkspecs/common/unix.conf \
        /usr/share/qt5/mkspecs/common/linux.conf \
        /usr/share/qt5/mkspecs/common/gcc-base.conf \
        /usr/share/qt5/mkspecs/common/gcc-base-unix.conf \
        /usr/share/qt5/mkspecs/common/g++-base.conf \
        /usr/share/qt5/mkspecs/common/g++-unix.conf \
        /usr/share/qt5/mkspecs/qconfig.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_3d.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_core.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_designer.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_gui.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_help.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_location.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_network.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qml.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_quick.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_script.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_sql.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_svg.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_v8.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_xml.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
        /usr/share/qt5/mkspecs/features/qt_functions.prf \
        /usr/share/qt5/mkspecs/features/qt_config.prf \
        /usr/share/qt5/mkspecs/linux-g++-64/qmake.conf \
        /usr/share/qt5/mkspecs/features/spec_post.prf \
        /usr/share/qt5/mkspecs/features/exclusive_builds.prf \
        /usr/share/qt5/mkspecs/features/default_pre.prf \
        /usr/share/qt5/mkspecs/features/unix/default_pre.prf \
        /usr/share/qt5/mkspecs/features/resolve_config.prf \
        /usr/share/qt5/mkspecs/features/default_post.prf \
        /usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \
        /usr/share/qt5/mkspecs/features/warn_on.prf \
        /usr/share/qt5/mkspecs/features/qt.prf \
        /usr/share/qt5/mkspecs/features/resources.prf \
        /usr/share/qt5/mkspecs/features/moc.prf \
        /usr/share/qt5/mkspecs/features/unix/opengl.prf \
        /usr/share/qt5/mkspecs/features/uic.prf \
        /usr/share/qt5/mkspecs/features/unix/thread.prf \
        /usr/share/qt5/mkspecs/features/wayland-scanner.prf \
        /usr/share/qt5/mkspecs/features/testcase_targets.prf \
        /usr/share/qt5/mkspecs/features/exceptions.prf \
        /usr/share/qt5/mkspecs/features/yacc.prf \
        /usr/share/qt5/mkspecs/features/lex.prf \
        gui2.pro \
        gui2.pro
QMAKE_TARGET  = gui2
DESTDIR       = 
TARGET        = gui2


first: all
####### Implicit rules

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
    $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: Makefile $(TARGET)

$(TARGET):  $(OBJECTS)  
    $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

Makefile: gui2.pro /usr/share/qt5/mkspecs/linux-g++-64/qmake.conf /usr/share/qt5/mkspecs/features/spec_pre.prf \
        /usr/share/qt5/mkspecs/common/shell-unix.conf \
        /usr/share/qt5/mkspecs/common/unix.conf \
        /usr/share/qt5/mkspecs/common/linux.conf \
        /usr/share/qt5/mkspecs/common/gcc-base.conf \
        /usr/share/qt5/mkspecs/common/gcc-base-unix.conf \
        /usr/share/qt5/mkspecs/common/g++-base.conf \
        /usr/share/qt5/mkspecs/common/g++-unix.conf \
        /usr/share/qt5/mkspecs/qconfig.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_3d.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_core.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_designer.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_gui.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_help.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_location.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_network.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qml.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_quick.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_script.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_sql.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_svg.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_v8.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_xml.pri \
        /usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
        /usr/share/qt5/mkspecs/features/qt_functions.prf \
        /usr/share/qt5/mkspecs/features/qt_config.prf \
        /usr/share/qt5/mkspecs/linux-g++-64/qmake.conf \
        /usr/share/qt5/mkspecs/features/spec_post.prf \
        /usr/share/qt5/mkspecs/features/exclusive_builds.prf \
        /usr/share/qt5/mkspecs/features/default_pre.prf \
        /usr/share/qt5/mkspecs/features/unix/default_pre.prf \
        /usr/share/qt5/mkspecs/features/resolve_config.prf \
        /usr/share/qt5/mkspecs/features/default_post.prf \
        /usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \
        /usr/share/qt5/mkspecs/features/warn_on.prf \
        /usr/share/qt5/mkspecs/features/qt.prf \
        /usr/share/qt5/mkspecs/features/resources.prf \
        /usr/share/qt5/mkspecs/features/moc.prf \
        /usr/share/qt5/mkspecs/features/unix/opengl.prf \
        /usr/share/qt5/mkspecs/features/uic.prf \
        /usr/share/qt5/mkspecs/features/unix/thread.prf \
        /usr/share/qt5/mkspecs/features/wayland-scanner.prf \
        /usr/share/qt5/mkspecs/features/testcase_targets.prf \
        /usr/share/qt5/mkspecs/features/exceptions.prf \
        /usr/share/qt5/mkspecs/features/yacc.prf \
        /usr/share/qt5/mkspecs/features/lex.prf \
        gui2.pro \
        /usr/lib/x86_64-linux-gnu/libQt5Widgets.prl \
        /usr/lib/x86_64-linux-gnu/libQt5Gui.prl \
        /usr/lib/x86_64-linux-gnu/libQt5Core.prl
    $(QMAKE) -o Makefile gui2.pro
/usr/share/qt5/mkspecs/features/spec_pre.prf:
/usr/share/qt5/mkspecs/common/shell-unix.conf:
/usr/share/qt5/mkspecs/common/unix.conf:
/usr/share/qt5/mkspecs/common/linux.conf:
/usr/share/qt5/mkspecs/common/gcc-base.conf:
/usr/share/qt5/mkspecs/common/gcc-base-unix.conf:
/usr/share/qt5/mkspecs/common/g++-base.conf:
/usr/share/qt5/mkspecs/common/g++-unix.conf:
/usr/share/qt5/mkspecs/qconfig.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_3d.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_core.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_designer.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_gui.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_help.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_location.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_network.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qml.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_quick.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_script.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_sql.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_svg.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_v8.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_xml.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri:
/usr/share/qt5/mkspecs/features/qt_functions.prf:
/usr/share/qt5/mkspecs/features/qt_config.prf:
/usr/share/qt5/mkspecs/linux-g++-64/qmake.conf:
/usr/share/qt5/mkspecs/features/spec_post.prf:
/usr/share/qt5/mkspecs/features/exclusive_builds.prf:
/usr/share/qt5/mkspecs/features/default_pre.prf:
/usr/share/qt5/mkspecs/features/unix/default_pre.prf:
/usr/share/qt5/mkspecs/features/resolve_config.prf:
/usr/share/qt5/mkspecs/features/default_post.prf:
/usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf:
/usr/share/qt5/mkspecs/features/warn_on.prf:
/usr/share/qt5/mkspecs/features/qt.prf:
/usr/share/qt5/mkspecs/features/resources.prf:
/usr/share/qt5/mkspecs/features/moc.prf:
/usr/share/qt5/mkspecs/features/unix/opengl.prf:
/usr/share/qt5/mkspecs/features/uic.prf:
/usr/share/qt5/mkspecs/features/unix/thread.prf:
/usr/share/qt5/mkspecs/features/wayland-scanner.prf:
/usr/share/qt5/mkspecs/features/testcase_targets.prf:
/usr/share/qt5/mkspecs/features/exceptions.prf:
/usr/share/qt5/mkspecs/features/yacc.prf:
/usr/share/qt5/mkspecs/features/lex.prf:
gui2.pro:
/usr/lib/x86_64-linux-gnu/libQt5Widgets.prl:
/usr/lib/x86_64-linux-gnu/libQt5Gui.prl:
/usr/lib/x86_64-linux-gnu/libQt5Core.prl:
qmake: FORCE
    @$(QMAKE) -o Makefile gui2.pro

qmake_all: FORCE

dist: 
    @test -d .tmp/gui21.0.0 || mkdir -p .tmp/gui21.0.0
    $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/gui21.0.0/ && $(COPY_FILE) --parents function.h hide/convertImage.h function.cpp .tmp/gui21.0.0/ && $(COPY_FILE) --parents main.cpp .tmp/gui21.0.0/ && (cd `dirname .tmp/gui21.0.0` && $(TAR) gui21.0.0.tar gui21.0.0 && $(COMPRESS) gui21.0.0.tar) && $(MOVE) `dirname .tmp/gui21.0.0`/gui21.0.0.tar.gz . && $(DEL_FILE) -r .tmp/gui21.0.0


clean:compiler_clean 
    -$(DEL_FILE) $(OBJECTS)
    -$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
    -$(DEL_FILE) $(TARGET) 
    -$(DEL_FILE) Makefile


mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

check: first

compiler_rcc_make_all:
compiler_rcc_clean:
compiler_wayland-server-header_make_all:
compiler_wayland-server-header_clean:
compiler_wayland-client-header_make_all:
compiler_wayland-client-header_clean:
compiler_moc_header_make_all: moc_function.cpp
compiler_moc_header_clean:
    -$(DEL_FILE) moc_function.cpp
moc_function.cpp: /usr/include/qt5/QtCore/QObject \
        /usr/include/qt5/QtCore/qobject.h \
        /usr/include/qt5/QtCore/qobjectdefs.h \
        /usr/include/qt5/QtCore/qnamespace.h \
        /usr/include/qt5/QtCore/qglobal.h \
        /usr/include/qt5/QtCore/qconfig.h \
        /usr/include/qt5/QtCore/qfeatures.h \
        /usr/include/qt5/QtCore/qsystemdetection.h \
        /usr/include/qt5/QtCore/qcompilerdetection.h \
        /usr/include/qt5/QtCore/qprocessordetection.h \
        /usr/include/qt5/QtCore/qlogging.h \
        /usr/include/qt5/QtCore/qflags.h \
        /usr/include/qt5/QtCore/qtypeinfo.h \
        /usr/include/qt5/QtCore/qtypetraits.h \
        /usr/include/qt5/QtCore/qsysinfo.h \
        /usr/include/qt5/QtCore/qobjectdefs_impl.h \
        /usr/include/qt5/QtCore/qstring.h \
        /usr/include/qt5/QtCore/qchar.h \
        /usr/include/qt5/QtCore/qbytearray.h \
        /usr/include/qt5/QtCore/qrefcount.h \
        /usr/include/qt5/QtCore/qatomic.h \
        /usr/include/qt5/QtCore/qbasicatomic.h \
        /usr/include/qt5/QtCore/qatomic_bootstrap.h \
        /usr/include/qt5/QtCore/qgenericatomic.h \
        /usr/include/qt5/QtCore/qatomic_msvc.h \
        /usr/include/qt5/QtCore/qatomic_integrity.h \
        /usr/include/qt5/QtCore/qoldbasicatomic.h \
        /usr/include/qt5/QtCore/qatomic_vxworks.h \
        /usr/include/qt5/QtCore/qatomic_power.h \
        /usr/include/qt5/QtCore/qatomic_aarch64.h \
        /usr/include/qt5/QtCore/qatomic_alpha.h \
        /usr/include/qt5/QtCore/qatomic_armv7.h \
        /usr/include/qt5/QtCore/qatomic_armv6.h \
        /usr/include/qt5/QtCore/qatomic_armv5.h \
        /usr/include/qt5/QtCore/qatomic_bfin.h \
        /usr/include/qt5/QtCore/qatomic_ia64.h \
        /usr/include/qt5/QtCore/qatomic_mips.h \
        /usr/include/qt5/QtCore/qatomic_s390.h \
        /usr/include/qt5/QtCore/qatomic_sh4a.h \
        /usr/include/qt5/QtCore/qatomic_sparc.h \
        /usr/include/qt5/QtCore/qatomic_x86.h \
        /usr/include/qt5/QtCore/qatomic_cxx11.h \
        /usr/include/qt5/QtCore/qatomic_gcc.h \
        /usr/include/qt5/QtCore/qatomic_unix.h \
        /usr/include/qt5/QtCore/qarraydata.h \
        /usr/include/qt5/QtCore/qstringbuilder.h \
        /usr/include/qt5/QtCore/qlist.h \
        /usr/include/qt5/QtCore/qalgorithms.h \
        /usr/include/qt5/QtCore/qiterator.h \
        /usr/include/qt5/QtCore/qcoreevent.h \
        /usr/include/qt5/QtCore/qscopedpointer.h \
        /usr/include/qt5/QtCore/qmetatype.h \
        /usr/include/qt5/QtCore/qvarlengtharray.h \
        /usr/include/qt5/QtCore/qcontainerfwd.h \
        /usr/include/qt5/QtCore/qisenum.h \
        /usr/include/qt5/QtCore/qobject_impl.h \
        function.h
    /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) function.h -o moc_function.cpp

compiler_wayland-code_make_all:
compiler_wayland-code_clean:
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean 

####### Compile

main.o: main.cpp function.h \
        /usr/include/qt5/QtCore/QObject \
        /usr/include/qt5/QtCore/qobject.h \
        /usr/include/qt5/QtCore/qobjectdefs.h \
        /usr/include/qt5/QtCore/qnamespace.h \
        /usr/include/qt5/QtCore/qglobal.h \
        /usr/include/qt5/QtCore/qconfig.h \
        /usr/include/qt5/QtCore/qfeatures.h \
        /usr/include/qt5/QtCore/qsystemdetection.h \
        /usr/include/qt5/QtCore/qcompilerdetection.h \
        /usr/include/qt5/QtCore/qprocessordetection.h \
        /usr/include/qt5/QtCore/qlogging.h \
        /usr/include/qt5/QtCore/qflags.h \
        /usr/include/qt5/QtCore/qtypeinfo.h \
        /usr/include/qt5/QtCore/qtypetraits.h \
        /usr/include/qt5/QtCore/qsysinfo.h \
        /usr/include/qt5/QtCore/qobjectdefs_impl.h \
        /usr/include/qt5/QtCore/qstring.h \
        /usr/include/qt5/QtCore/qchar.h \
        /usr/include/qt5/QtCore/qbytearray.h \
        /usr/include/qt5/QtCore/qrefcount.h \
        /usr/include/qt5/QtCore/qatomic.h \
        /usr/include/qt5/QtCore/qbasicatomic.h \
        /usr/include/qt5/QtCore/qatomic_bootstrap.h \
        /usr/include/qt5/QtCore/qgenericatomic.h \
        /usr/include/qt5/QtCore/qatomic_msvc.h \
        /usr/include/qt5/QtCore/qatomic_integrity.h \
        /usr/include/qt5/QtCore/qoldbasicatomic.h \
        /usr/include/qt5/QtCore/qatomic_vxworks.h \
        /usr/include/qt5/QtCore/qatomic_power.h \
        /usr/include/qt5/QtCore/qatomic_aarch64.h \
        /usr/include/qt5/QtCore/qatomic_alpha.h \
        /usr/include/qt5/QtCore/qatomic_armv7.h \
        /usr/include/qt5/QtCore/qatomic_armv6.h \
        /usr/include/qt5/QtCore/qatomic_armv5.h \
        /usr/include/qt5/QtCore/qatomic_bfin.h \
        /usr/include/qt5/QtCore/qatomic_ia64.h \
        /usr/include/qt5/QtCore/qatomic_mips.h \
        /usr/include/qt5/QtCore/qatomic_s390.h \
        /usr/include/qt5/QtCore/qatomic_sh4a.h \
        /usr/include/qt5/QtCore/qatomic_sparc.h \
        /usr/include/qt5/QtCore/qatomic_x86.h \
        /usr/include/qt5/QtCore/qatomic_cxx11.h \
        /usr/include/qt5/QtCore/qatomic_gcc.h \
        /usr/include/qt5/QtCore/qatomic_unix.h \
        /usr/include/qt5/QtCore/qarraydata.h \
        /usr/include/qt5/QtCore/qstringbuilder.h \
        /usr/include/qt5/QtCore/qlist.h \
        /usr/include/qt5/QtCore/qalgorithms.h \
        /usr/include/qt5/QtCore/qiterator.h \
        /usr/include/qt5/QtCore/qcoreevent.h \
        /usr/include/qt5/QtCore/qscopedpointer.h \
        /usr/include/qt5/QtCore/qmetatype.h \
        /usr/include/qt5/QtCore/qvarlengtharray.h \
        /usr/include/qt5/QtCore/qcontainerfwd.h \
        /usr/include/qt5/QtCore/qisenum.h \
        /usr/include/qt5/QtCore/qobject_impl.h \
        function.cpp \
        /usr/include/qt5/QtWidgets/QApplication \
        /usr/include/qt5/QtWidgets/qapplication.h \
        /usr/include/qt5/QtCore/qcoreapplication.h \
        /usr/include/qt5/QtCore/qeventloop.h \
        /usr/include/qt5/QtGui/qwindowdefs.h \
        /usr/include/qt5/QtGui/qwindowdefs_win.h \
        /usr/include/qt5/QtCore/qpoint.h \
        /usr/include/qt5/QtCore/qsize.h \
        /usr/include/qt5/QtGui/qcursor.h \
        /usr/include/qt5/QtWidgets/qdesktopwidget.h \
        /usr/include/qt5/QtWidgets/qwidget.h \
        /usr/include/qt5/QtCore/qmargins.h \
        /usr/include/qt5/QtGui/qpaintdevice.h \
        /usr/include/qt5/QtCore/qrect.h \
        /usr/include/qt5/QtGui/qpalette.h \
        /usr/include/qt5/QtGui/qcolor.h \
        /usr/include/qt5/QtGui/qrgb.h \
        /usr/include/qt5/QtCore/qstringlist.h \
        /usr/include/qt5/QtCore/qdatastream.h \
        /usr/include/qt5/QtCore/qiodevice.h \
        /usr/include/qt5/QtCore/qpair.h \
        /usr/include/qt5/QtCore/qregexp.h \
        /usr/include/qt5/QtCore/qstringmatcher.h \
        /usr/include/qt5/QtGui/qbrush.h \
        /usr/include/qt5/QtCore/qvector.h \
        /usr/include/qt5/QtGui/qmatrix.h \
        /usr/include/qt5/QtGui/qpolygon.h \
        /usr/include/qt5/QtGui/qregion.h \
        /usr/include/qt5/QtCore/qline.h \
        /usr/include/qt5/QtGui/qtransform.h \
        /usr/include/qt5/QtGui/qpainterpath.h \
        /usr/include/qt5/QtGui/qimage.h \
        /usr/include/qt5/QtGui/qpixmap.h \
        /usr/include/qt5/QtCore/qsharedpointer.h \
        /usr/include/qt5/QtCore/qshareddata.h \
        /usr/include/qt5/QtCore/qsharedpointer_impl.h \
        /usr/include/qt5/QtCore/qhash.h \
        /usr/include/qt5/QtGui/qfont.h \
        /usr/include/qt5/QtGui/qfontmetrics.h \
        /usr/include/qt5/QtGui/qfontinfo.h \
        /usr/include/qt5/QtWidgets/qsizepolicy.h \
        /usr/include/qt5/QtGui/qkeysequence.h \
        /usr/include/qt5/QtGui/qevent.h \
        /usr/include/qt5/QtCore/qvariant.h \
        /usr/include/qt5/QtCore/qmap.h \
        /usr/include/qt5/QtCore/qdebug.h \
        /usr/include/qt5/QtCore/qtextstream.h \
        /usr/include/qt5/QtCore/qlocale.h \
        /usr/include/qt5/QtCore/qset.h \
        /usr/include/qt5/QtCore/qcontiguouscache.h \
        /usr/include/qt5/QtCore/qurl.h \
        /usr/include/qt5/QtCore/qurlquery.h \
        /usr/include/qt5/QtCore/qfile.h \
        /usr/include/qt5/QtCore/qfiledevice.h \
        /usr/include/qt5/QtGui/qvector2d.h \
        /usr/include/qt5/QtGui/qtouchdevice.h \
        /usr/include/qt5/QtGui/qguiapplication.h \
        /usr/include/qt5/QtGui/qinputmethod.h \
        /usr/include/qt5/QtWidgets/QWidget \
        /usr/include/qt5/QtWidgets/QGridLayout \
        /usr/include/qt5/QtWidgets/qgridlayout.h \
        /usr/include/qt5/QtWidgets/qlayout.h \
        /usr/include/qt5/QtWidgets/qlayoutitem.h \
        /usr/include/qt5/QtWidgets/qboxlayout.h \
        /usr/include/qt5/QtWidgets/QSpinBox \
        /usr/include/qt5/QtWidgets/qspinbox.h \
        /usr/include/qt5/QtWidgets/qabstractspinbox.h \
        /usr/include/qt5/QtGui/qvalidator.h \
        /usr/include/qt5/QtWidgets/QLabel \
        /usr/include/qt5/QtWidgets/qlabel.h \
        /usr/include/qt5/QtWidgets/qframe.h \
        /usr/include/qt5/QtWidgets/QGraphicsScene \
        /usr/include/qt5/QtWidgets/qgraphicsscene.h \
        /usr/include/qt5/QtGui/qpen.h \
        /usr/include/qt5/QtWidgets/QGraphicsView \
        /usr/include/qt5/QtWidgets/qgraphicsview.h \
        /usr/include/qt5/QtGui/qpainter.h \
        /usr/include/qt5/QtGui/qtextoption.h \
        /usr/include/qt5/QtWidgets/qscrollarea.h \
        /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
        /usr/include/qt5/QtWidgets/QGraphicsPixmapItem \
        /usr/include/qt5/QtWidgets/qgraphicsitem.h
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

moc_function.o: moc_function.cpp 
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_function.o moc_function.cpp

####### Install

install:   FORCE

uninstall:   FORCE

FORCE:

2 个答案:

答案 0 :(得分:2)

正如clang试图告诉你的那样,你忘记了openCV命名空间。

使用:

cv::Mat cvImage;

using namespace cv;

请参阅documentation

答案 1 :(得分:2)

我发现我所要做的就是将我需要的库包含在Makefile中的“LIBS”中。所以这是解决方案,在Makefile的LIBS末尾或底部添加行

`LIBS += pkg-config --libs opencv`

这一行实际上可以添加到Makefile的“编译器,工具和选项”部分的任何位置(请参阅原始问题中发布的Makefile代码)。

此外,我缺乏“命名空间”也是一个问题!