一个简单的vector 的c++ 程序, 编译错误
#include <vector>
int main()
{
std::vector<int> vet;
}
错误原因:使用的gcc 命令(应该使用g++命令)
gcc :
“GCC” is a common shorthand term for the GNU Compiler Collection. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs (as the abbreviation formerly stood for “GNU C Compiler”).
使用gcc 编译c++程序,虽然gcc也能识别出c++,但gcc并不会加载c++ library
g++:
而使用g++ 编译c++程序,会调用gcc而且会自动加载c++ library
please refer:
* http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/G_002b_002b-and-GCC.html
* man g++
#include <vector>
int main()
{
std::vector<int> vet;
}
错误原因:使用的gcc 命令(应该使用g++命令)
gcc :
“GCC” is a common shorthand term for the GNU Compiler Collection. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs (as the abbreviation formerly stood for “GNU C Compiler”).
使用gcc 编译c++程序,虽然gcc也能识别出c++,但gcc并不会加载c++ library
g++:
而使用g++ 编译c++程序,会调用gcc而且会自动加载c++ library
please refer:
* http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/G_002b_002b-and-GCC.html
* man g++
本文介绍了一个简单的 C++ 程序中使用 vector 的编译错误,并解释了使用 gcc 和 g++ 命令的区别。当使用 gcc 编译包含 C++ 标准库的程序时会出现错误,正确做法应使用 g++ 进行编译。
1468

被折叠的 条评论
为什么被折叠?



