Eclipse cdt 无法解析 c++ 中的外部实体项目

发布于 2025-01-06 13:14:27 字数 482 浏览 2 评论 0原文

我的 Eclipse C++ 项目问题是 Eclipse 无法解析外部函数、命名空间、变量等... 请看截图。

在此处输入图像描述

更大的一个

因此,例如 jni 类型 jint 不会被 Eclipse 解析,但是,如您所见 jni.h 是包含并解决(我可以 CNTRL+单击它并查看其内容),我已经设置了所有需要的包含路径,因此所有文件都按预期包含在内,但 Eclipse 不会解析其中的实体。

问题可能出在哪里?

附言。我是使用 eclipse 进行 c++ 开发的新手,所以我可能会错过一些东西,请帮助我,我将非常感激。

谢谢。

My problem with eclipse c++ project that eclipse could not resolve extern functions, namespaces, variables, etc...
Please, see the screenshot.

enter image description here

Bigger one

So, for example jni type jint is not resolved by eclipse, but, as you can see jni.h is included and resolved (I can CNTRL+click on it and view its content), I've set up all needed include path, so all files are included as they supposed to, but eclipse doesn't resolve entities from them.

Where the problem might be there?

PS. I'm a newbbie in the c++ development with eclipse, so I might miss something, please help me, I'll appreciate it a lot.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

み零 2025-01-13 13:14:27

您还需要告诉 Eclipse 您的 JNI 库在哪里。

如果您从未执行过此操作,请查看此 wiki 条目。关于链接的部分包含图片、箭头和文本,可以引导您完成整个过程。

一些一般建议:学会区分编译器错误和链接器错误。如果是编译器错误,那么您可以查找丢失的包含文件等。当它是链接器错误时,这意味着它已编译并找到所有标头都很好,但当它寻找要链接到的实际对象时却找不到它。这通常意味着您需要解决库路径问题。

最后一个警告,我已经看到 Eclipse 自行更改了工具链设置,我 将其写在博客文章中

You also need to tell Eclipse where you JNI library is.

If you've never done this, see this wiki entry. The section on linking has pictures and arrows and text that should walk you through the process.

Some general advice: Learn to distinguish between compiler errors and linker errors. If it's a compiler error, then you can look for missing include files etc. When it's a linker error it means it compiled and found all the headers just fine but when it went looking for the actual object to link to it couldn't find it. That typically means you have a library path issue to resolve.

One final warning, I have seen Eclipse change the toolchain settings all by itself, I wrote this up in a blog entry if you want to see the one settings panel I now always avoid.

守望孤独 2025-01-13 13:14:27

正如 krasilich 所说,当链接器面临不明确的变量并在链接过程中出现混乱时,就会发生这种情况。

当我遇到这个问题时,我通过重新编辑变量的标头“包含外部声明”暂时解决了这个问题,清理并再次构建,链接器将能够轻松发现并链接它。但永久的解决方案是在 C/C++ 常规 > 路径和符号 > 包含中添加包含头文件的工作区/文件夹路径。

可能的解释是依赖于编译器和链接器。我尝试用 GCC 来做到这一点,没有出现任何问题。当我使用像 GHS 这样的私有编译器时,特定变量会出现此问题。

This happens as krasilich said, when the linker faces an ambiguous variable and mess up in linking.

I fixed this problem temporarily when i faced it by re-edit the variable's header "the one includes the extern declaration", Clean and build again and the linker will be able to spot and link it in ease. But the permanent solution was by adding the workspace/folder path that includes the header file in C/C++ General>Paths and Symbols>Includes.

Possible explanation is a compiler and linker dependent. I tried to do that wit GCC without problems. When i use a private compiler like GHS this problem occurs with specific variables.

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