0

I am trying to install core-plot into my iPhone project following these directions. Coreplot requires that I use the LLVM gcc 4.2 compiler, and this is causing notation problems.

Because I am using LLVM gcc 4.2, the @autorelease notation produces the error "Expected expression before '@' token" in main.m.

int main(int argc, char *argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }

}

Because of this I got rid of the @autoreleasepool notation and changed main to look like the following.

int main(int argc, char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    [pool release];
    return retVal;
}

However this gives the 'NSAutoreleasePool is unavailable" error since I am using ARC. So I added the -fno-objc-arc compiler flag to main.m, which gave me and "unrecognized command line option "-fno-objc-arc" error.

Is there a way to resolve the notation problems caused by using LLVC gcc 4.2 while using ARC in my project?

Bae
  • 43
  • 7
  • possible duplicate of [CorePlot 1.0 + LLVM GCC 4.2 + ARC - How to?](http://stackoverflow.com/questions/10769230/coreplot-1-0-llvm-gcc-4-2-arc-how-to) – Brad Larson Jun 07 '12 at 22:16

1 Answers1

0

ARC cannot be used with gcc-llvm. You have a few options. You could build CorePlot separately as a static library and link it into your project. You could even embed the CorePlot project file in yours and have it built as a dependency with its own build configuration. You could also switch CorePlot over to clang. I got 1.0 to build once I removed the custom C options. ARC integrates with non-ARC code just fine.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37
  • Thanks, I'll try building as a static library and see how that goes. – Bae Jun 07 '12 at 20:44
  • I followed the static library instructions [here](http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications) except for 5. which says to change the C compiler to LLVM GCC 4.2. Everything seems to be working. I'm just curious, do you know why they recommend LLVM GCC 4.2? – Bae Jun 07 '12 at 20:53
  • @Rebecca - We don't. Nowhere in the dependent project instructions does it say to use LLVM GCC, and the static library instructions say "Change your C/C++ Compiler in the project build settings to LLVM GCC 4.2 or LLVM 1.6." We're a little out of date, with 3.1 being the current version of the LLVM compiler in Xcode, but we support building with all compilers shipping with Xcode. Personally, I highly recommend following the dependent project instructions (which I wrote) and using LLVM for your project's compiler, because that's the cleanest way to integrate the framework in your application. – Brad Larson Jun 07 '12 at 22:23