gpt4 book ai didi

c++ - qt #include 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:52:31 27 4
gpt4 key购买 nike

我正在尝试在 qt 中使用 std::vector,但我似乎遇到了一些错误,每当我包含 vector header 并编译以下代码时,我都会得到一大堆错误但是当我删除 vector header 并编译相同的代码时,它工作正常。

#include <iostream>
#include <vector>

using namespace std;

int main ()
{

std::cout<<"Vector"<<std::endl;
return 0;
}

由于有很多错误,我决定将它们放入一个文件中并提供下面的链接。

http://goo.gl/XOj0nV

构建日志的开头和结尾:

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.

我希望所提供的信息足以满足我的查询需求。

最佳答案

我刚才遇到了和你一样的问题。我写了一个名为 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”),一切都会好起来的。希望我的回答能帮到你。

关于c++ - qt #include <vector> 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26014695/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com