如何修复G ++库

时间:2019-06-24 16:49:19

标签: c++ g++

我一直在尝试使用g ++ / gcc .cpp在Windows 7中从cmd编译并运行c ++文件,它给了我这个:

  

“ C:\ Users \ Owner \ AppData \ Local \ Temp \ ccnsWJzo.o:hello.cpp :(。text + 0x19):对`std :: cout'的未定义引用”

我检查了MinGW文件中的库,并且缺少“ iostream”库(以及我的代码都需要的“ fstream”库)。

在编译方面,我仅有的经验来自Dev-c ++,我只需要按一下按钮即可编译并自动运行。

我尝试使用vscode,但是在编译时给我一个错误,它说“。”不是可执行文件,因此我决定从cmd进行编译和运行,它可以识别g ++并且可以“编译”-或至少可以尝试。

我尝试编译: "c:\Users\Owner\projects\helloworld>gcc hello.cpp"

这些都是错误:

  

“ C:\ Users \ Owner \ AppData \ Local \ Temp \ ccbV5Efo.o:hello.cpp :(。text + 0x19):对'std :: cout'的未定义引用

     

C:\ Users \ Owner \ AppData \ Local \ Temp \ ccbV5Efo.o:hello.cpp :(。text + 0x1e):未定义引用'std :: basic_ostream>&std :: operator <<>(std :: basic_ostream>&,char const *)'

     

C:\ Users \ Owner \ AppData \ Local \ Temp \ ccbV5Efo.o:hello.cpp :(。text + 0x35):对'std :: ios_base :: Init ::〜Init()的未定义引用< / p>      

C:\ Users \ Owner \ AppData \ Local \ Temp \ ccbV5Efo.o:hello.cpp :(。text + 0x56):对'std :: ios_base :: Init :: Init()'的未定义引用      

collect2.exe:错误:ld返回1个退出状态”

我希望它只是在cmd中打印“ hello world”并完成代码的执行,但是...如您所见,它不会那样做

0 个答案:

没有答案