错误:'vector'没有命名类型/错误:在'<'之前的','或'...' token / error:'vector'尚未声明 [英] error: 'vector' does not name a type / error: expected ',' or '...' before '<' token / error: 'vector' has not been declared
问题描述
我在Ubuntu 15.04上使用Qt Creator。我刚刚使用文档网站(此处: https://help.ubuntu.com)上提供的脚本安装了OpenCV 3.0 / community / OpenCV )。当编译我的代码时,我得到一些错误(运行脚本之前不存在):
I am using Qt Creator on Ubuntu 15.04. I just installed OpenCV 3.0 using the script provided on the documentation website (here: https://help.ubuntu.com/community/OpenCV). When compiling my code i get some errors (not present before running the script):
/ usr / include / opencv2 / gpu / gpu。 hpp:432:error:'vector'没有命名类型
CV_EXPORTS void merge(const vector& src,GpuMat& dst,Stream& stream = Stream :: Null());
/usr/include/opencv2/gpu/gpu.hpp:432: error: 'vector' does not name a type CV_EXPORTS void merge(const vector& src, GpuMat& dst, Stream& stream = Stream::Null());
/usr/include/opencv2/gpu/gpu.hpp:432:错误:在'<'token [..]之前的','或'...'
/usr/include/opencv2/gpu/gpu.hpp:432: error: expected ',' or '...' before '<' token [..]
/usr/include/opencv2/gpu/gpu.hpp:438:错误:'vector'尚未声明[..]
/usr/include/opencv2/gpu/gpu.hpp:438: error: 'vector' has not been declared [..]
除了第一个错误外,所有错误都列在gpu.hpp中:
All the errors are listed to be in 'gpu.hpp' besides the first one which is:
/ [..] / main.cpp:6:在包含于../[..]/ main.cpp:6:0的文件中:
/[..]/main.cpp:6: In file included from ../[..]/main.cpp:6:0:
指向我放置opencv2 / gpu / gpu.hpp包含的行。
referring to the line in which I put the opencv2/gpu/gpu.hpp include.
我在Stackoverflow中搜索过很多,并在include之前移动了using namespace std,但这只是改变了错误类型(他们都转到
I searched Stackoverflow a lot and moved 'using namespace std' before the includes but this just changes the error type (they all turn to
错误:未定义引用`cv :: Mat :: zeros(int,int,int)'
error: undefined reference to `cv::Mat::zeros(int, int, int)'
或类似的东西)。
包括我放在代码的顶部是:
The includes I put at the top of the code are:
- iostream
- stdio.h
- opencv2 / opencv.hpp,opencv2 / highgui / highgui_c。 h,opencv2 / imgproc / imgproc_c.h,opencv2 / gpu / gpu.hpp,opencv2 / core / core.hpp
- 向量
- h
- cmath
- 列表
- fstream
- iomanip
- iostream
- stdio.h
- opencv2/opencv.hpp, opencv2/highgui/highgui_c.h, opencv2/imgproc/imgproc_c.h, opencv2/gpu/gpu.hpp, opencv2/core/core.hpp
- vector
- math.h
- cmath
- list
- fstream
- string
- iomanip
+
using namespace std;
using namespace std;
using namespace cv;
using namespace cv;
我的.pro专案档案是:
My .pro project file is:
QT + = core gui
QT += core gui
greaterThan(QT_MAJOR_VERSION,4):QT + = widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FinalMultimedia
TARGET = FinalMultimedia
TEMPLATE = app
TEMPLATE = app
LIBS + = -lopencv_core
LIBS += -lopencv_core
LIBS + = -lopencv_imgproc
LIBS += -lopencv_imgproc
LIBS + = -lopencv_highgui
LIBS += -lopencv_highgui
SOURCES + = main.cpp \
SOURCES += main.cpp\
运行Makefile(make VERBOSE = 1)我得到:
Running the Makefile (make VERBOSE=1) I get:
g ++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I ../ try -I。 -isystem / usr / include / x86_64-linux-gnu / qt5 -isystem / usr / include / x86_64-linux-gnu / qt5 / QtWidgets -isystem / usr / include / x86_64-linux-gnu / qt5 / QtGui -isystem / usr / include / x86_64-linux-gnu / qt5 / QtCore -I。 -I / usr / lib / x86_64-linux-gnu / qt5 / mkspecs / linux-g ++ - 64 -o main.o ../ try / main.cpp
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../try -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o main.o ../try/main.cpp
其中opencv库根本不出现(dunno为什么)。我使用gcc / g ++刚刚运行更新/升级,所以我想它将是5.1.1。我是一个完整的Linux初学者,所以我想弄明白。任何帮助?非常感谢。
in which opencv libraries do not appear at all (dunno why). I am using gcc/g++ having just run update/upgrade so I guess it'll be 5.1.1. I am a complete Linux beginner, so I'm trying to figure it out. Any help? thank you very much.
更新:
我试图创建一个新的Eclipse项目, 。我设置正确的include / libraries(以前一直在ecplipse使用opencv / c ++)。我得到相同的错误。 wtf
I tried to create a new Eclipse project with the same code inside. I set the right include / libraries (had been using opencv / c++ in ecplipse a while ago). I get the same error. wtf
推荐答案
移动命名空间线确实解决了编译问题。未定义的引用是一个链接问题。恭喜!这是进步。
Moving the namespace line did solve the compilation problem. The undefined reference is a linking problem. Congrats! That's progress.
现在你只需要确定哪个opencv lib有这个符号,并确认你的搜索路径正在查找(他们可能不是)。您可以使用 readelf
查看任何特定库中的符号。你缺少的符号可能应该在opencv_core内,但我不知道。你必须确认。 nm
也可能会帮助你。使用 man
查看它们是如何工作的 - 两者都很容易。
Now you just have to determine which opencv lib has that symbol and confirm that your search paths are looking there (They probably are not). You can use readelf
to see the symbols inside any particular library. Your missing symbol probably supposed to be inside opencv_core, but I don't know that. You'll have to confirm. nm
might help you, too. Use man
to see how they work -- both are easy.
您还可以跟踪make文件Qt创建和使用它从命令行。添加VERBOSE = 1可查看每个要求的库,并为库搜索指定每个路径。
You can also track down the make file Qt creates, and use it from the command line. Add VERBOSE=1 to see every library asked for, and every path spelled out for library searches.
这篇关于错误:'vector'没有命名类型/错误:在'<'之前的','或'...' token / error:'vector'尚未声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!