Netbeans C / C ++链接器问题(Netbeans C/C++ linker problem)

编程入门 行业动态 更新时间:2024-10-24 01:49:08
Netbeans C / C ++链接器问题(Netbeans C/C++ linker problem)

在Linux上的Netbeans 6.9中,我试图编译我的C ++代码。 它由两个CPP文件组成 - main.cpp和后来的我将Tree.cpp和Tree.h添加到项目中,但是链接器显然忽略了这一事实,并在使用Tree中的某些东西时在main.cpp中引发“未定义的引用错误”单元。

你有任何线索如何正确地添加CPP文件到项目,所以它链接成功?

谢谢!

In Netbeans 6.9 on Linux and I was trying to to compile my C++ code. It consists of two CPP files - main.cpp and later I added Tree.cpp and Tree.h to the project, but linker obviously ignores that fact and throws an "undefined reference error" in main.cpp when I use something from the Tree unit.

Do you have any clue how to add the CPP file to the project properly so it links successfully?

Thanks!

最满意答案

您需要将Tree.cpp添加到项目的构建配置中; 您还需要在“搜索文件”构建部分中将路径添加到Tree.h中。

右键单击您的项目并选择“属性”,然后转到C ++编译器部分。 在“包含目录”中添加Tree.h的路径。 现在再次右键单击您的项目并选择“添加现有项目”,并选择“Tree.cpp”。 最后清理和重建,你的项目应该很好地建立。

You need to add Tree.cpp to your project's build configuration; also you need to add the path to Tree.h in the "Search files" build section.

Right-click your project and select "properties", then go to the C++ compiler section. In "include directories" add the path to Tree.h. Now right click your project again and select "add existing items", and choose "Tree.cpp". Finally Clean and Rebuild, and your project should be built nicely.

更多推荐

本文发布于:2023-04-27 16:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:链接   Netbeans   problem   linker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!