Log in or register to post comments

How to #import QCAR C++ Header File in iPhone/iPad Project

January 31, 2013 - 3:26am #1

 

 
First, I don't think it is an issue concerning any bugs of Vuforia. It is about how Vuforia organizes its namespace
 
Here is the simple version of the problem:
 
I have a huge project. Vuforia has ObjC++ headers, other libraries I use has ObjC headers and sources, my project codes also include ObjC headers and sources.
When I tried to import Vuforia headers(e.g. #import <QCAR/QCAR.h>), Xcode prompts "no type named namespace". which means in an ObjC environment, it could not recognized C++ keyword namespace.
 
I have tried:
1. Modify the file type my project codes to `Obj C++ source`, which is equivalent to change from `.m` to `.mm`
2. Modify my codes that they would strictly follow C++ standard(like assign a void* pointer to an int* pointer)
Well, LLVM just raises me a link error,like
 
"pinyinFirstLetter(unsigned short)", referenced from:
     -[NSString(LocaleHelper) stringForIndexTitle] in LocaleHelper.o
ld: symbol(s) not found for architecture armv7
 
This function is in other libraries I used. So I guess I HAVE TO modify other libraries to force them follow C++ standard, but that's NOT what I want.
 
I am using:
  • Native SDK
  • MacOS version number 10.8.2
  • Xcode version number 4.5, Apple LLVM 4.1(GCC 4.2 would raise more awkward errors)
  • iOS 6.0

How to #import QCAR C++ Header File in iPhone/iPad Project

January 31, 2013 - 9:07am #2

Hi ComboZhc,

I have checked with the technicial gurus here to find the best way forward for you

Vuforia is a C++ API, so there is no way to call it from C or Objective C.  Instead you need to use C++ or Objective C++.

The recommendation here is that you could write a single Objective C++ file that contains all your calls to Vuforia so that this file acts as an interface.  However you will need to use "extern C" to ensure that you don't get the C++ name mangling applied.

EDIT

You may be in for quite a bit of work here, because the wrapper class cannot take as parameters or return any of the QCAR:: objects.  The other option you have here is to make this wrapper class completely self-contained, and only communicate your main app directly i.e. not using QCAR objects.  This way, you can encapsulate your app’s interaction with Vuforia into one source file.

HTH

 

EDIT

More info here:

http://stackoverflow.com/questions/3799169/how-to-wrap-a-c-lib-in-objective-c?rq=1

 

Log in or register to post comments