Tôi đã cố gắng xây dựng một chương trình đơn giản trong thiết bị đầu cuối.Không thể biên dịch chương trình C++ đơn giản trong Ubuntu
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("TESTING");
return 1;
}
Tôi chạy g ++ -o test test.cpp
Các lỗi:
/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
Danh sách này vẫn tiếp tục theo cách này. Tôi hy vọng ai đó có thể chỉ ra những gì tôi đã không làm để thực hiện công việc này.
Thử nghiệm 'g ++ --verbose -o test.cpp' cung cấp cho bạn những gì? – genpfault
xem liệu http://ubuntuforums.org/showthread.php?t=1877944 có giúp –
Tôi có thể khắc phục được sự cố không. Tôi đã kiểm tra đầu ra tiết và quyết định đơn giản hóa đường dẫn. Tôi đã đổi thành chỉ /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Chương trình biên dịch ngay bây giờ, nhưng nó không xuất ra bất cứ thứ gì khi chạy . Điều đó có bình thường không? –