linux Clion cmake出现错误 undefined reference to `std::cout‘

Clon执行时 出现如下错误:

/usr/bin/cmake --build /home/lenong0427/CLionProjects/untitled2/cmake-build-debug --target untitled2
[1/1] Linking CXX executable untitled2
FAILED: untitled2 
: && /usr/bin/gcc -g  CMakeFiles/untitled2.dir/main.cpp.o -o untitled2   && :
/usr/bin/ld: CMakeFiles/untitled2.dir/main.cpp.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
/usr/bin/ld: CMakeFiles/untitled2.dir/main.cpp.o: in function `main':
/home/lenong0427/CLionProjects/untitled2/main.cpp:54: undefined reference to `std::cout'
/usr/bin/ld: /home/lenong0427/CLionProjects/untitled2/main.cpp:54: undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: /home/lenong0427/CLionProjects/untitled2/main.cpp:54: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_tra

#include <iostream&gt; int main() { std::cout << "Hello MinGW!" << std::endl; return 0; }正在启动生成... cmd /c chcp 65001>nul && D:\gongzuo\minGW\mingw64\bin\gcc.exe -fdiagnostics-color=always -g D:\gongzuo\c++study\study1.cc -o D:\gongzuo\c++study\study1.exe C:\Users\hcl\AppData\Local\Temp\ccs5wWxN.o: In function `main': D:/gongzuo/c++study/study1.cc:3: undefined reference to `std::basic_ostream&lt;char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream&lt;char, std::char_traits<char> >&, char const*)' D:/gongzuo/c++study/study1.cc:3: undefined reference to `std::ostream::operator<<(std::ostream&amp; (*)(std::ostream&amp;))' C:\Users\hcl\AppData\Local\Temp\ccs5wWxN.o: In function `__tcf_0': D:/gongzuo/minGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::~Init()' C:\Users\hcl\AppData\Local\Temp\ccs5wWxN.o: In function `__static_initialization_and_destruction_0': D:/gongzuo/minGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()' C:\Users\hcl\AppData\Local\Temp\ccs5wWxN.o:study1.cc:(.rdata$.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_[.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]+0x0): undefined reference to `std::basic_ostream&lt;char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream&lt;char, std::char_traits<char> >&)' C:\Users\hcl\AppData\Local\Temp\ccs5wWxN.o:study1.cc:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined reference to `std::cout' collect2.exe: error: ld returned 1 exit status
最新发布
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值