我正在尝试在Sublime text中编译 c++ 。我已经设法在我的计算机上安装了MinGw的相关软件包。除了在C:\MinGW\bin目录下的 System 环境变量中创建一个路径文件,它的确切位置。随后在编辑器中生成了一个新的构建系统,包含以下内容:
{
"cmd" : "gcc $file_name -o ${file_base_name} && ${file_base_name}",
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}
如果我的编译器安装正确完成,我进一步检查了 cmd,确实如此。
>gcc --version
gcc (MinGW.org GCC Build-2) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我输入了崇高的代码:
#include<iostream>
using namespace std;
int main(){
cout<<"hello world";
}
编译结果是这样的:
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\44750\AppData\Local\Temp\ccVYP6T2.o:item.cpp:(.text+0x19): undefined reference to `std::cout'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\44750\AppData\Local\Temp\ccVYP6T2.o:item.cpp:(.text+0x1e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\44750\AppData\Local\Temp\ccVYP6T2.o:item.cpp:(.text+0x35): undefined reference to `std::ios_base::Init::~Init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\44750\AppData\Local\Temp\ccVYP6T2.o:item.cpp:(.text+0x56): undefined reference to `std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
[Finished in 0.8s]