首先,iostream是c头文件,因此您需要找到linux下g头文件的安装目录。
echo | g -v -x c -E -
确认以下结果。 # include ' . ' searchstartshere : # include . searchstartshere 3360/usr/include/c/5/usr/include/x86 include
/etc /配置文件中
以及source /etc/profile
创建hello.cpp试验
# include stdio.h # includeiostreamusingnamespacestd; intmain(void ) { cout'hello'endl; 打印(hello world (n ) ); 返回0; } g hello.cpp -o hello
很好。
在eclipse下,在project-properties下的C build和C general下添加头文件。
eclipse下的文件在使用c的库时,必须使用cpp而不是. c。 我犯了这个错误。 不小心使用了. c,invoking了gcc。 而且它找不到g的头文件。