Reflex - All You Need to Know

I wanted to create a thread where I would post all of my findings and efforts to make Reflex, which is such an awesome feature, available and accessible to people who want to use it from other projects - such as myself. I have a particular issue where I like to develop for the UNIX platform on Windows using Cygwin and Eclipse. My manager makes fun of me all the time that I like Cygwin because he says back in the day we used to have a better unix emulator made by MKS. Unfortunately, we use MKS Integrity for our source control where I work and as time passes I am starting to like it more and more… when people ask me what I think of it, I say “I like it”, followed by a pause and then I say “Stockholm Syndrome has set in for me of course”

Anyway, my goals are to provide simple and implicit instructions for how somebody can download a certain source code repository from the ROOT project and compile and use Reflex to determine information about their own custom C++ classes in a simple, easy to use manner. i.e. I want someone not familiar with this project to be able to have C++ Reflection!

Note: I plan on editing this first posting to always contain the latest instructions right under this line. Hopefully by the end of this effort, the full instruction set will be under this line!

So, I have had much success in building and installing ROOT with Reflex support. This only works for version 5.34, as later versions have changed things up a bit. So, if your goal is to compile ROOT with Reflex support in a cygwin environment, follow this guide:

[1] Install cygwin and select at the bare minimum the following packages:

Web::wget
Devel::subversion

[2] Install apt-cyg, a command-line based cygwin package manager:

mkdir ~/apt-install
cd ~/apt-install
svn co apt-cyg.googlecode.com/svn/trunk
cd trunk
chmod +x apt-cyg

[3] Apply a patch to fix apt-cyg for the new cygwin repository format:

Download patch file from the 3rd comment on this page: (Use a browser, I can’t figure out how to get a direct link)

code.google.com/p/apt-cyg/issues/detail?id=26

Then execute the patch (place johns_patch2.diff into the same directory)

svn patch johns_patch2.diff

[4] Move apt-cyg to the user local bin directory, perform some cleanup:

mv apt-cyg /usr/local/bin/
cd ~
rm -rf apt-install

[5] Install git, make, and a couple of other required tools:

apt-cyg update
apt-cyg install git
apt-cyg install make
apt-cyg install gcc
apt-cyg install libfreetype-devel
apt-cyg install gcc-fortran
apt-cyg install python
apt-cyg install cmake

[6] Install GccXML (Added this step on August 26th, 2013)

git clone git://github.com/gccxml/gccxml.git
cd gccxml
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/gccxml
make
make install
cd …
rm -rf gccxml
echo “export PATH=/usr/local/gccxml/bin:$PATH” >> ~/.bash_profile
source ~/.bash_profile

[7] Clone the ROOT Git repository (Around 660 Megabytes, so this can time some time).

mkdir ~/root
cd ~/root
git clone root.cern.ch/git/root.git root-v5-34

[8] Checkout version 5.34

cd root-v5-34
git fetch origin
git checkout -b v5-34-09 origin/v5-34-00-patches

[9] Build (Note, in this version of ROOT, Reflex is not enabled by default)

./configure win32gcc --prefix=/usr/local/reflex.gcc --minimal --enable-reflex
make
make install

[10] Add the bin directory to your path:

echo “export PATH=/usr/local/reflex/bin:$PATH” >> ~/.bash_profile
source ~/.bash_profile

[11] Fix reference to “genreflex” python script from “genreflex” shell script

The script located in /usr/local/reflex/bin/ is incorrectly referencing the python script located in /usr/local/reflex/lib/root/python/genreflex

sed -i “s;lib/python;lib/root/python;” /usr/local/reflex/bin/genreflex

[12] Fix the core dumped error that occurs after running the script:

This is a cygwin specific bug, I don’t know why this resolves this other than a poor/erroneous implementation of something in this Python package. Regardless, a way of getting rid of this error is to change the order in which the subprcess package is imported by the python script:

First, get rid of the subprocess reference:
sed -i “s/,\ subprocess//” /usr/local/reflex/lib/root/python/genreflex/genreflex.py

Second, add it back before the first import statement
sed -i “s/import\ /import\ subprocess,\ /” /usr/local/reflex/lib/root/python/genreflex/genreflex.py

Finished!

Finally… it now works on cygwin

I got Annotations working successfully today! All on the cygwin environment. I will post instructions that are fully (hopefully) reproducible from a brand new cygwin installation soon.