ROOT with Cocoa
Ok, so I'm trying to write a program in cocoa that will call the root libraries for graphing, and I've figured out how to get the libraries to work in a c++ command line too project in xcode, but I'm having trouble getting it to work with Obj-C. Turns out that ROOT has a class named "Class" which conflicts with a really low level Obj-C class (or something.. I'm not exactly sure what the heck is going on.) Anyway, it looks like I can't get at the root libraries from within a .m or .mm file. SO I'm wondering if there is any way to link a button in Interface Builder to a c++ function, without having to resort to an obj-c method as an intermediary?
Sample code that compiles and runs, but doesn't ever call the ROOT stuff (replace imports in ' ' with the > and <:
//
// main.mm
// MacHeliosSim
//
#import 'Foundation/Foundation.h'
#import 'Cocoa/Cocoa.h'
int main(int argc, char *argv[])
{
//bob( argc, argv);
return NSApplicationMain(argc, (const char **) argv);
}
/*
* RootGunk.cpp
* MacHeliosSim
*
* Created by Paul Thompson on 7/26/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#import 'iostream'
#import "TH1D.h"
#import "TApplication.h"
using namespace std;
int bob( int argc, char** argv) {
TApplication app("fctest", &argc, argv);
TH1D* myhisto=new TH1D("myhisto","myhisto",10,0,10);
myhisto->Fill(3);
myhisto->Fill(3);
myhisto->Fill(3);
myhisto->Fill(5);
myhisto->Draw();
cout<<"Program Finished"<< endl;
app.Run();
return 0;
}
Replace the name 'bob' with 'main' and the code from RootGunk.cpp will work correctly by itself (after applying the appropriate linker flags and such, of course). If I call bob from main.mm, though, it won't compile. If I call it from main, but change the name to main.cpp, and remove the references to the cocoa libraries, it compiles. I just can't get both at the same time.
So, has anyone got any ideas?




I had this problem as well.
I had this problem as well. I expect you've read the same ROOT forum posts about it as I have. Someone had some success with clang/llvm, but it didn't seem like they were really doing what you (and I) wanted. I think it's not a trivial task - maybe you want to join the ROOT dev team and get it working :)