未找到符号,预计出现在平面命名空间 ObjC++
我可能遇到了一个简单的问题,但是在编译过程中没有任何信息性错误或警告来提醒我出了什么问题。
我有一个 Objective-C++ 应用程序,其中包含 C++ 主文件和 ObjC 头文件。
它构建得很好,但是在运行时,它会给出以下错误消息:
Dyld Error Message:
Symbol not found: _OBJC_CLASS_$_AppController
Referenced from: /Users/slate/Documents/osirixplugins/eqOsirix/build/Development/rcOsirix.app/Contents/MacOS/rcOsirix
Expected in: flat namespace
in /Users/slate/Documents/osirixplugins/eqOsirix/build/Development/rcOsirix.app/Contents/MacOS/rcOsirix
没有多少谷歌搜索能够找到解决方案,而且我确信我只是在某个地方错过了编译或构建选项。
“AppController.h”包含在目标中(已选中),并且 #import
包含在 ObjC 类文件中。
非常感谢任何帮助。
ObjC++ 总是让我头疼。
谢谢,
-S!
I've got probably what is a simple problem, but there's no informative errors or warnings during compile to alert me to what is going wrong.
I've got a Objective-C++ app that includes a C++ main and ObjC header files.
It builds fine, but when run, it gives this error message:
Dyld Error Message:
Symbol not found: _OBJC_CLASS_$_AppController
Referenced from: /Users/slate/Documents/osirixplugins/eqOsirix/build/Development/rcOsirix.app/Contents/MacOS/rcOsirix
Expected in: flat namespace
in /Users/slate/Documents/osirixplugins/eqOsirix/build/Development/rcOsirix.app/Contents/MacOS/rcOsirix
No amount of googling has resulted in a solution, and I'm sure I've just missed a compilation or build option somewhere.
"AppController.h" is included in the target (checked), and #import
'd in the ObjC Class File.
Any help is greatly appreciated.
ObjC++ constantly gives me a headache.
Thanks,
-S!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然 AppController 类丢失了。 AppController类是在动态库框架中定义的吗?如果是这样,当您运行应用程序时,它是否知道在哪里可以找到库/框架?
顺便说一下,这是一个链接器问题。头文件是无关紧要的。您需要查看的是 .m 或 .mm 文件。
Clearly the AppController class is missing. Is the AppController class defined in a framework of dynamic library? If so, when you run the app, does it know where to find the libraries/frameworks?
This is a linker issue, by the way. The header files are irrelevant. It's the .m or .mm files you need to look at.
不确定这是否是你的问题,但我在 C++ dll 上遇到了类似的问题,这花了我一整天的时间来调试。我大约有 15 年没有用 C++ 编程了,在尝试编写纯虚函数时,我使用了熟悉的语法“virtual void f();” ——哎呀。在 C++ 中,它应该是“virtual void f() == 0;” mac OSX 10.9.2 上最新版本的 gcc 可以愉快地编译代码。
我认为这是一个完全合法的前向声明...但是,不确定 C++ 是否允许类跨越多个文件,因此似乎应该对此进行标记(因为 CXX 文件中没有提供任何实现。)无论如何,符号将其放入目标代码中,并且链接器永远不会抱怨,因此您最终会得到丢失的引用。希望这对某人有帮助。
Not sure if this is your issue, but I was having a similar problem with a C++ dll, which took me all day to debug. I haven't programmed in C++ for around 15 years, and while attempting to write a pure virtual function, I used the familiar syntax "virtual void f();" -- oops. In C++ it should be "virtual void f() == 0;" The latest version of gcc on mac OSX 10.9.2 happily compiles the code.
I think it's a perfectly legal forward declaration... however, not sure if C++ allows classes to span multiple files, so it seems like this should be flagged (as no implementation is ever supplied in the CXX file.) In any event, the symbol makes it into the object code, and the linker never complains, so you end up with the missing reference. Hope this helps someone.