标签:https 环境变量 shell lan cts inf img cout 排查
到这里下载GCC预编译包:https://sourceforge.net/projects/mingw-w64/files
下载这个:

将其内 mingw/bin 目录配到 PATH 环境变量下,使用命令 g++ -v,得到版本信息:

这里用 stl 库中的 vector 容器。
#include <iostream>
#include <vector>
int main(){
vector<int> vec1(10, 4);
for (int i = 0; i< vec1.size(); i++){
std::cout << vec1[i] << std::endl;
}
system("pause");
return 0;
}
g++ .\hello.cpp -o hello
报失败...

排查原因,是因为 vector 类前要加 std::
#include <iostream>
#include <vector>
int main(){
std::vector<int> vec1(10, 4);
for (int i = 0; i< vec1.size(); i++){
std::cout << vec1[i] << std::endl;
}
system("pause");
return 0;
}
然后编译成功了,在 hello.cpp 同级别目录下生成了 hello.exe 文件
双击运行,按理说应该出现10行4,然后等按任意键结束,但是报错:

排查原因,是因为一个动态链接库有问题...
找到g++的动态链接库 mingw/bin/libstdc++-6.dll,放到 hello.exe 旁边,正常运行:

标签:https 环境变量 shell lan cts inf img cout 排查
原文地址:https://www.cnblogs.com/onsummer/p/13291324.html