Linux 上的 Netbeans 中的代码帮助

发布于 2024-09-03 16:51:29 字数 822 浏览 3 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

錯遇了你 2024-09-10 16:51:29

它对我来说效果很好。我正在使用 NetBeans 6.8;我得到的唯一未定义的引用是 add() 函数。

您可以用一个新项目进行测试,看看是否可以重现该问题吗?

编辑(回复):

是的,在 Linux 上测试过。项目属性中未添加任何内容。

在全局 C/C++ 选项中,我有一个额外的 C 包含路径,/usr/include/i486-linux-gnu
对于 C++ 我有:

/usr/include/c++/4.4
/usr/include/c++/4.4/i486-linux-gnu
/usr/include/c++/4.4/backward
/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/i486-linux-gnu
/usr/include

这些是我的默认值,没有触及它们。华泰
我还使用 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:

/usr/include/c++/4.4
/usr/include/c++/4.4/i486-linux-gnu
/usr/include/c++/4.4/backward
/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/i486-linux-gnu
/usr/include

These are my defaults, haven't touched them. HTH
I also use gcc-4.4.3 (Ubuntu 10.04).

紫﹏色ふ单纯 2024-09-10 16:51:29

你有适当的包含吗?

如果我没记错的话,你需要

#include <iostream>

Do you have the proper includes?

If I remember correctly, you need to

#include <iostream>
去了角落 2024-09-10 16:51:29

转到“工具”->“选项”->“C/C++”->“构建工具”,它将显示 NetBeans 正在使用的编译器。
例如,

    /usr/bin/g++

在终端中键入:

    $ whereis g++
    g++: /usr/bin/g++ /usr/bin/X11/g++ /usr/share/man/man1/g++.1.gz
    $ ls -al /usr/bin/g++
    lrwxrwxrwx 1 root root 7 Mar 13  2012 /usr/bin/g++ -> g++-4.6

将显示 Netbeans 正在使用的编译器版本。如果“代码帮助”选项卡中的库不匹配,您需要将它们更改为正确版本的库。
例如

    /usr/include/c++/4.6
    ...
    /usr/lib/gcc/i686-linux-gnu/4.6/include-fixed

等等。

Go to Tools->Options->C/C++->Build tools, it will show the compiler NetBeans is using.
E.g.

    /usr/bin/g++

Typing in a terminal:

    $ whereis g++
    g++: /usr/bin/g++ /usr/bin/X11/g++ /usr/share/man/man1/g++.1.gz
    $ ls -al /usr/bin/g++
    lrwxrwxrwx 1 root root 7 Mar 13  2012 /usr/bin/g++ -> g++-4.6

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.

    /usr/include/c++/4.6
    ...
    /usr/lib/gcc/i686-linux-gnu/4.6/include-fixed

and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文