简体   繁体   English

符号未找到,预期在Flat Namespace ObjC ++中

[英]Symbol Not Found, expected in Flat Namespace ObjC++

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. 我有一个Objective-C ++应用程序,其中包含C ++主文件和ObjC头文件。

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. “AppController.h”包含在目标(已检查)中,而#import import'd包含在ObjC类文件中。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

ObjC++ constantly gives me a headache. ObjC ++经常让我头疼。

Thanks, 谢谢,

-S! -S!

Clearly the AppController class is missing. 显然缺少AppController类。 Is the AppController class defined in a framework of dynamic library? AppController类是在动态库的框架中定义的吗? 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. 这是您需要查看的.m或.mm文件。

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();" 我没有在C ++中编程大约15年,在尝试编写纯虚函数时,我使用了熟悉的语法“virtual void f();” -- oops. - 哎呀 In C++ it should be "virtual void f() == 0;" 在C ++中它应该是“virtual void f()== 0;” The latest version of gcc on mac OSX 10.9.2 happily compiles the code. mac OSX 10.9.2上最新版本的gcc很高兴地编译代码。

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. 我认为这是一个完全合法的前向声明...但是,不确定C ++是否允许类跨越多个文件,所以看起来应该标记这个(因为CXX文件中没有提供任何实现。)无论如何,符号使其成为目标代码,并且链接器永远不会抱怨,因此您最终会得到缺少的引用。 Hope this helps someone. 希望这有助于某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM