Netbeans特定的C ++错误“对XXX的未定义引用"; -(已发布解决方案) [英] Netbeans-specific C++ error "Undefined reference to XXX" - (Solution posted)

查看:81
本文介绍了Netbeans特定的C ++错误“对XXX的未定义引用"; -(已发布解决方案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个问题上苦苦挣扎了5到6个小时,把头发拔了出来,直到我终于找到了解决方案.我想将其发布(不确定是否有特定的位置发布未解决问题的解决方案),以作为可能遇到相同困难的其他人的解决方案.

I wrangled with this problem for a good 5 or 6 hours, pulling my hair out until I finally found a solution. I wanted to post this (not sure if there is a specific place to post solutions to unasked questions) as a solution for others who may run into the same difficulty.

我正在在Linux Mint Lisa上运行的Netbeans 7.1.1中编码一个C ++项目,并在尝试使用静态变量时不断收到未定义对XXX的引用"错误.来自C#的背景,因此对头文件等不太熟悉,我搜索了数小时,希望发现声明变量或类的方式存在问题.我什么都找不到...

I am coding a C++ project in Netbeans 7.1.1 running on Linux Mint Lisa, and kept on getting an "Undefined reference to XXX" error when trying to use a static variable. Coming from a background in C# and thus not very familiar with header files and the like, I searched for hours expecting to find a problem with the way I declared my variable or my class. I couldn't find anything...

推荐答案

转到Netbeans中文件浏览器中的nbproject文件夹.打开configuration.xml文件.向下滚动到具有属性名称="SourceFiles"的logicalFolder标记.确保您的所有.h和.cpp文件都作为logicalFolder标记中的itemPath标记包含! Netbeans正确地添加了一些但不是全部的cpp和h文件,因此出现了问题.由于所有类和头文件都是通过同一Netbeans向导添加的,因此不确定为什么会有这种不一致.无论如何,随着配置文件的更改,makefile会被更新并正确写入下一个版本中,并且所有功能均按预期运行.希望这可以帮助到别人!

Go to your nbproject folder in the files explorer in Netbeans. Open up the configurations.xml file. Scroll down to the logicalFolder tag with the attribute name="SourceFiles". Make sure that all your .h and .cpp files are included as itemPath tags within the logicalFolder tag! Netbeans correctly added some, but not all of my cpp and h files, hence the problem. Not sure why there would be this inconsistency, as all class and header files were added through the same Netbeans wizard. Anyways, with the configurations file changed, the makefiles were then updated and written correctly on the next build and all functioned as expected. Hope this can help somebody!

这篇关于Netbeans特定的C ++错误“对XXX的未定义引用"; -(已发布解决方案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆