C++ 在 MaveRicks 更新后未在 NetBeans 中编译

c++ not compiling in netbeans after mavericks update

本文关键字:NetBeans 编译 MaveRicks 更新 C++      更新时间:2023-10-16

像往常一样,在发布之前,我尝试阅读了许多论坛,谷歌答案,但仍然找不到问题。我有一段工作正常的代码。它在任何 linux dist 中编译,之前在美洲狮中编译,并且从终端编译,当我尝试通过 netbeans 7.4 编译它时,我收到以下错误下面是编译命令:

g++    -c -g -I../../Downloads/boost_1_50_0 -I. -I../../Downloads/RInside/inst/include -I/Library/Developer/CommandLineTools/usr/bin/../lib/clang/5.0/include -I/ -I/Library/Developer/CommandLineTools/usr/include -I/usr/include -I/usr/include/c++/4.2.1 -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp

这是错误

In file included from main.cpp:7:
In file included from /usr/include/c++/4.2.1/cstdlib:71:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
/usr/include/sys/resource.h:193:2: error: unknown type name 'uint8_t'
uint8_t  ri_uuid[16];
    ^
/usr/include/sys/resource.h:194:2: error: unknown type name 'uint64_t'
uint64_t ri_user_time;

第7行内容如下:

#include <cstdlib>

我想这是包含库的问题,但这只是一个猜测,我重新安装了netbeans,获得了java 1.7.0_45,安装了命令行工具,删除cache_dir,仍然是同样的问题,真正奇怪的部分是当我从终端编译它时

g++ main.cpp -o main -I./

那行得通....以前我有美洲狮的时候它就起作用了......任何帮助将不胜感激。最好乔治

好的,所以一个朋友建议开始删除库,直到命令运行(因为使用简单的 sintax,它在命令终端中运行),这正是我所做的,这就是导致问题的库:

-I/Library/Developer/CommandLineTools/usr/bin/../lib/clang/5.0/include

似乎当 mavericks 更新时它会切换到 clang,所以不知何故,这一行导致了代码正确编译的问题,我希望我对正在发生的事情有一个正确的答案,但至少这会解决问题,任何正确的答案将不胜感激:)

类似的问题也发生在我身上(但对于叮当声)。Brew帮助我解决了这个问题。 brew doctor列出了很多头文件(全部/usr/include/,有一些警告我现在不记得了。

简单地移动这些头文件对我有用。