Linux 上的 Netbeans 中的代码帮助
我的 IDE (NetBeans) 认为这是错误的代码,但它编译正确:
std::cout << "i = " << i << std::endl;
std::cout << add(5, 7) << std::endl;
std::string test = "Boe";
std::cout << test << std::endl;
它总是说 无法解析标识符 .... (.... = cout, endl, string);
所以我认为它与代码帮助有关。我想我必须更改/添加/删除一些文件夹。目前,我有以下包含文件夹:
C 编译器:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include-fixed
/usr/include
C++ 编译器:
/usr/include/c++/4.4.3
/usr/include/c++/4.4.3/i486-linux-gnu
/usr/include/c++/4.4.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/include
可能导致此问题的原因是什么,如何让 NetBeans 将其标记为有效代码?
My IDE (NetBeans) thinks this is wrong code, but it compiles correctly:
std::cout << "i = " << i << std::endl;
std::cout << add(5, 7) << std::endl;
std::string test = "Boe";
std::cout << test << std::endl;
It always says unable to resolve identifier .... (.... = cout, endl, string);
So I think it has something to do with the code assistance. I think I have to change/add/remove some folders. Currently, I have these include folders:
C compiler:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include-fixed
/usr/include
C++ compiler:
/usr/include/c++/4.4.3
/usr/include/c++/4.4.3/i486-linux-gnu
/usr/include/c++/4.4.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/include
What could be causing this, and how can I make NetBeans mark it as valid code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它对我来说效果很好。我正在使用 NetBeans 6.8;我得到的唯一未定义的引用是 add() 函数。
您可以用一个新项目进行测试,看看是否可以重现该问题吗?
编辑(回复):
是的,在 Linux 上测试过。项目属性中未添加任何内容。
在全局 C/C++ 选项中,我有一个额外的 C 包含路径,
/usr/include/i486-linux-gnu
。对于 C++ 我有:
这些是我的默认值,没有触及它们。华泰
我还使用 gcc-4.4.3 (Ubuntu 10.04)。
It works fine for me. I'm using NetBeans 6.8; the only undefined reference I got was for the add() function.
Can you test with a new project to see if you can reproduce the problem?
EDIT (reply):
Yep, tested on Linux. No includes added in project properties.
In the global C/C++ options I have an extra include path for C,
/usr/include/i486-linux-gnu
.For C++ I have:
These are my defaults, haven't touched them. HTH
I also use gcc-4.4.3 (Ubuntu 10.04).
你有适当的包含吗?
如果我没记错的话,你需要
Do you have the proper includes?
If I remember correctly, you need to
转到“工具”->“选项”->“C/C++”->“构建工具”,它将显示 NetBeans 正在使用的编译器。
例如,
在终端中键入:
将显示 Netbeans 正在使用的编译器版本。如果“代码帮助”选项卡中的库不匹配,您需要将它们更改为正确版本的库。
例如
等等。
Go to Tools->Options->C/C++->Build tools, it will show the compiler NetBeans is using.
E.g.
Typing in a terminal:
Will show which version of the compiler Netbeans is using. If the libraries in the Code Assistance tab do not match, you need to change them for the ones of the right version.
E.g.
and so on.