我正在尝试在qt中使用std::vector
,但我似乎遇到了一些错误,当我包含矢量标头并编译下面的代码时,我得到一个很大的错误列表但是当我删除矢量标题和编译相同的代码它工作正常。
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
std::cout<<"Vector"<<std::endl;
return 0;
}
由于存在很多错误,我决定将它们放入文件并提供以下链接。
构建日志的开头和结尾:
12:03:19: Running steps for project vector...
12:03:19: Configuration unchanged, skipping qmake step.
12:03:19: Starting: "/usr/bin/make"
g++ -c -pipe -g -Wall -W -fPIE -I../../Qt/5.3/gcc/mkspecs/linux-g++ -I../vector -I. -o main.o ../vector/
main.cpp
In file included from ../vector/main.cpp:2:0:
./vector:1:1: error: stray '\177' in program
./vector:1:1: error: stray '\1' in program
./vector:1:1: error: stray '\1' in program
./vector:1:1: error: stray '\1' in program
./vector:1:8: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\2' in program
./vector:1:18: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\3' in program
./vector:1:20: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\1' in program
./vector:1:22: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\205' in program
./vector:1:1: error: stray '\4' in program
./vector:1:1: error: stray '\10' in program
./vector:1:30: warning: null character(s) ignored [enabled by default]
[...]
./vector:115:880: warning: null character(s) ignored [enabled by default]
./vector:115:886: warning: null character(s) ignored [enabled by default]
In file included from ../vector/main.cpp:2:0:
File: /home/sanjayan/Documents/qt_vector_errors Page 76 of 76
./vector:1:2: error: 'ELF' does not name a type
In file included from ../vector/main.cpp:2:0:
./vector:28:655: error: 'j' does not name a type
In file included from ../vector/main.cpp:2:0:
./vector:61:28: error: expected declaration before '}' token
make: *** [main.o] Error 1
12:03:22: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project vector (kit: Desktop Qt 5.3 GCC 32bit)
When executing step 'Make'
12:03:22: Elapsed time: 00:03.
我希望提供的信息足以满足我的查询要求。
答案 0 :(得分:0)
我和你刚才有同样的问题。 我写了一个名为vector.cc的C ++程序
#include <iostream>
#include <vector>
using namespace std;
int main()
{
cout << "hello" << endl;
return 0;
}
编译可以第一次传递(使用g++ vector.cc -o vector
,创建一个名为vector
的可执行文件),然后任何包含句子#include vector
的程序将面临您所说的问题。
基本原因是vector
文件,如果删除了可执行文件(名为"vector"
),一切都会正常。
我希望我的回答可以帮到你。