Symbol Not Found, expected in Flat Namespace ObjC++
Asked Answered
A

2

10

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!

Aldwon answered 8/4, 2010 at 14:48 Comment(0)
T
6

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.

Telescopic answered 11/4, 2010 at 18:52 Comment(1)
Yes, actually, it was a namespace issue in the .m file that included the AppController.h which caused it to not be in the binary at all. GCC threw no errors though, so I had no idea what was wrong. Thanks.Aldwon
C
2

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.

Cemetery answered 12/4, 2014 at 6:3 Comment(1)
This has definitely helped me. Thanks for the hint. I forgot to add = 0 to one of the methods of my abstract class.Soekarno

© 2022 - 2024 — McMap. All rights reserved.