Use a C++ file in Cocoa iPhone App


Use a C++ file in Cocoa iPhone App



I'm trying to use the functionality of the example iPhone app AQOfflineRenderTest in my app (this app specifically isn't important, I just thought it worth mentioning). I have a C++ file with method called:

    void DoAQOfflineRender(CFURLRef sourceURL, CFURLRef destinationURL) 

I'm trying to call this from my Cocoa Objective-C class. The example app I referenced above does this by declaring the method in the header file like so:

    - (IBAction)doSomethingAction:(id)sender;     @end     void DoAQOfflineRender(CFURLRef sourceURL, CFURLRef destinationURL); 

In the implementation file I call the doSomethingAction which calls renderAudio and executes the same code:

    DoAQOfflineRender(sourceURL, destinationURL); 

When I execute I get the error: _DoAQOfflineRender", referenced from: -[myViewController renderAudio] in myViewController.o symbol(s) not found collect2: ld returned 1 exit status

Am I missing a reference to this C++ class? It doesn't specify one in the example app but it runs.

Please help and thanks!

Joe


Converting OpenGL Primitives to OpenGLES

1:

EXC_BAD_ACCESS error
What you're missing is the implementation of DoAQOfflineRender -- did you forreceive to link in the library where this routine is defined?. casting a NSString to char problem
Trying to include iPhone OpenGLES headers in C++ codeIs NSTimer auto retained?

2:

Submit ajax form on keyboard close without a submit button on the iphone?
It looks like you're using .m as the extension for you Objective-C source file so the compiler thinks you are referencing a C function. Why does this create a memory leak (iPhone)? Try changing the extension to .mm.. UICachedDeviceWhiteColor and NSAutoRelease for table cell mem leaks

3:

To call a C++ function from a C or Objective-C file, you need declare it with extern "C" linkage in C++..
#if __cplusplus extern "C" { #endif  void DoAQOfflineRender(CFURLRef sourceURL, CFURLRef destinationURL);  #if __cplusplus } #endif 
The reason for this is this C++ functions’ names are modified by encoding their types, so this functions with the same name although different signatures become different symbols. For example, DoAQOfflineRender(CFURLRef, CFURLRef) becomes __Z17DoAQOfflineRenderPK7__CFURLS1_ without extern "C", although _DoAQOfflineRender with it, which is what the C/Objective-C expects..


74 out of 100 based on 59 user ratings 1084 reviews