Compiling a HippoDraw Program on Mac OS X

I've recently been working on switching over to HippoDraw to get away from depending on ROOT for drawing plots. While I haven't yet gotten it installed on Linux (thanks to Qt taking forever to install), but I have gotten it working on my laptop under OS X. It took a little work to figure out how to get the example program to compile, mainly because HippoDraw is (unfortunately) written against Qt 3, rather than Qt 4, so I want to at least have a record of it.

Install Qt (version 4.5 was what I got)

Install HippoDraw (For this I used a branch maintained privately within my workgroup, so my installation was a bit different than what other people would see.) I installed it to /usr/local.

Write a test program. For this I copied the one given in the documentation, neatening it up a bit as I went. Here's my version:

#include <string>
#include <vector>
#include <controllers/DisplayController.h>
#include <datasrcs/NTuple.h>
#include <datasrcs/NTupleController.h>
#include <plotters/PlotterBase.h>
#include <qt/QtApp.h>
#include <qt/QtViewWidget.h>

using std::string;
using std::vector;
using hippodraw::NTupleController;
using hippodraw::NTuple;
using hippodraw::DisplayController;
using hippodraw::PlotterBase;
using hippodraw::QtViewWidget;

int main( int argc, char* argv[]){
    QApplication app(argc, argv);

    const string filename("/Path/To/hippodraw/src/examples/aptuple.tnt");
    NTupleController* nt_controller = NTupleController::instance();
    NTuple* nt = (hippodraw::NTuple*)nt_controller->createNTuple(filename);

    nt_controller->registerNTuple(nt);
    const string histo("Histogram");
    vector<string> bindings;
    bindings.push_back("Cost");

    DisplayController* dc_controller = DisplayController::instance();
    PlotterBase* plotter = dc_controller->createDisplay(histo, *nt, bindings);
    QtViewWidget* view = new QtViewWidget();
    view->setPlotter(plotter);
    view->resize(200, 200);
    app.setMainWidget(view);
    view->setCaption("Qt HippoDraw - View widget");
    view->show();

    int result = app.exec();
    delete view;
    delete nt;

    return(result);
}

Write a makefile to compile it. Here's what I came up with, assuming the above is saved as main.cpp:

PRODUCT = hippoTest
SOURCE = main.cpp

CC = g++
CCFLAGS = -Os -I/usr/local/include -I/usr/local/include/HippoDraw/ -I/Library/Frameworks/Qt3Support.framework/Headers -I/Library/Frameworks/QtGui.framework/Headers -I/Library/Frameworks/QtXml.framework/Headers -I/Library/Frameworks/QtCore.framework/Headers -DQT3_SUPPORT
LDFLAGS =-L/usr/local/lib/ -lhippo -framework QtCore -framework QtGui -framework Qt3Support

.PHONY: all $(PRODUCT)

all : $(PRODUCT)

$(PRODUCT) : $(SOURCE)
    $(CC) $(CCFLAGS) $(SOURCE) $(LDFLAGS) -o $(PRODUCT)

This should be sufficient to get the example program to compile and run.

No Comments

Comment on this post