g ++找不到标准的C ++库

时间:2016-02-02 20:55:08

标签: c++ g++

我有一个包含标准<iostream>标题的hello world C ++文件。系统是Ubuntu 14.04

计划是:

#include <iostream>
using namespace std;

int main(){
    cout << endl;
    cout << "Hello " <<endl;
   return 0;
}

用g ++构建它:

g++ main.cpp -o main

给出:

In file included from main.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note:   ‘std::cout’
extern ostream cout;  /// Linked to standard output
              ^
main.cpp:6:13: error: ‘endl’ was not declared in this scope
cout << endl;
         ^
main.cpp:6:13: note: suggested alternative:
In file included from /usr/include/c++/4.8/iostream:39:0,
             from main.cpp:1:
/usr/include/c++/4.8/ostream:564:5: note:   ‘std::endl’
endl(basic_ostream<_CharT, _Traits>& __os)
 ^
hello.cpp: In function ‘void print_hello()’:
hello.cpp:5:4: error: ‘cout’ was not declared in this scope
cout << "Hello World!";
^
hello.cpp:5:4: note: suggested alternative:
In file included from hello.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note:   ‘std::cout’
extern ostream cout;  /// Linked to standard output

我是否需要在某处配置标准库的路径?

修改

我将<iostream.h>更改为<iostream>,但问题仍然是另一种形式。

0 个答案:

没有答案