我试图在终端中构建一个简单的程序。无法在Ubuntu中编译简单的C++程序
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("TESTING");
return 1;
}
我跑的g ++ -o测试TEST.CPP
的错误:
/usr/include/features.h:323:26: error: bits/predefs.h: No such file or directory
/usr/include/features.h:356:25: error: sys/cdefs.h: No such file or directory
/usr/include/features.h:388:23: error: gnu/stubs.h: No such file or directory
In file included from test.cpp:2:
/usr/include/stdlib.h:42:29: error: bits/waitflags.h: No such file or directory
/usr/include/stdlib.h:43:30: error: bits/waitstatus.h: No such file or directory
/usr/include/stdlib.h:320:49: error: sys/types.h: No such file or directory
In file included from test.cpp:2:
/usr/include/stdlib.h:35: error: ‘__BEGIN_DECLS’ does not name a type
/usr/include/stdlib.h:102: error: expected constructor, destructor, or type conversion before ‘;’ token
/usr/include/stdlib.h:113: error: ‘__END_NAMESPACE_STD’ does not name a type
/usr/include/stdlib.h:122: error: expected constructor, destructor, or type conversion before ‘;’ token
/usr/include/stdlib.h:140: error: expected constructor, destructor, or type conversion before ‘extern’
/usr/include/stdlib.h:145: error: expected constructor, destructor, or type conversion before ‘extern’
/usr/include/stdlib.h:149: error: expected initializer before ‘__THROW’
/usr/include/stdlib.h:152: error: expected initializer before ‘__THROW’
/usr/include/stdlib.h:153: error: ‘__END_NAMESPACE_STD’ does not name a type
/usr/include/stdlib.h:160: error: ‘__END_NAMESPACE_C99’ does not name a type
/usr/include/stdlib.h:168: error: ‘__END_NAMESPACE_STD’ does not name a type
名单还在继续这种方式。我希望有人能指出我没有做的工作。
什么'g ++ --verbose -o test test.cpp给你? – genpfault 2012-02-15 23:24:48
看看http://ubuntuforums.org/showthread.php?t=1877944有帮助 – 2012-02-15 23:30:35
我可能已经解决了这个问题。我检查了详细的输出并决定简化路径。我将它改为 /usr/local/sbin:/ usr/local/bin:/ usr/sbin:/ usr/bin:/ sbin:/ bin 程序现在编译,但运行时不输出任何内容。这是正常的吗? – 2012-02-15 23:44:07