本文介绍了非常简单的程序无法在C ++中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么它不起作用...
I can't figure out why this isn't working...
我正在Linux中工作
I am working in Linux
g ++不执行任何操作
g++ doesn't do anything
gcc打印以下内容:
gcc prints the following:
/tmp/ccyg7NDd.o: In function `main':
test.cc:(.text+0x14): undefined reference to `std::cout'
test.cc:(.text+0x19): 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*)'
test.cc:(.text+0x21): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
test.cc:(.text+0x29): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccyg7NDd.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cc:(.text+0x51): undefined reference to `std::ios_base::Init::Init()'
test.cc:(.text+0x56): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccyg7NDd.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
代码:
#include<iostream>
#include<stdio.h>
int main(){
std::cout<<"test "<<std::endl;
return 0;
};
推荐答案
gcc main.cpp -lstdc++
或
g++ main.cpp
这篇关于非常简单的程序无法在C ++中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!