我試圖在終端中構建一個簡單的程序。無法在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