Archive for the ‘ Crystalspace / CEL ’ Category

Compiling RakNet With g++ 4.3 Fails

When choosing a networking library for a Crystalspace/CEL project of mine, my heart was set on RakNet. The RakNet library offers many features and does so in a way that makes it easy to integrate into almost any project.

Raknet is a cross-platform C++ game networking engine. It is designed to be a high performance, easy to integrate, and complete solution for games and other applications.

http://www.jenkinssoftware.com

Unfortunately, on my Ubuntu Jaunty system, g++-4.3 was installed by default which caused RakNet to fail on compilation. There were a bunch of errors in the DS_Map.h include file, including:

../Raknet/DS_Map.h:90: error: template argument 3 is invalid

After some trial and error I found that if you install the g++-4.2 development package and use the g++-4.2 binary, RakNet compiles and runs just fine.

From a terminal window:
sudo apt-get install g++-4.2

After installing the package above, I also needed to change which g++ binary my Eclipse project was using. I did this by going to the “Project” menu and clicking “Properties”. When the Properties window opens, click on “C/C++ Build” on the left side, then click on “GCC C++ Compiler” on the right. Where it shows the command to be run, change the command to read: g++-4.2.

eclipse_gcc_42

I enjoy playing around with the Crystalspace engine in my spare time but was disappointed when I first tried to use it on my Ubuntu Jaunty system. Eclipse was installed as the primary IDE, along with Eclipse CDT which is also known as the C/C++ Development Tools for Eclipse. Everything appeared to work alright except when it came to using the newly compiled Crystalspace libraries inside of a new project.

One of the best features about modern IDEs is auto completion, or as Eclipse calls it Content Assist. Its job is to monitor what you type and offer you possible functions that you have access to from within the current context. For example, if I had the following declared in my new CS project:

csRef<iPcDefaultCamera> pccamera = CEL_QUERY_PROPCLASS_ENT (player_entity, iPcDefaultCamera);

You would then be able to type pccamera followed by ->. When this is seen by the content assist, it builds a list of possible functions that the pccamera variable has access to call and displays them to you as a pop up listbox.

content_assist_1

The image of content assist in action shown above took about 1.5 seconds to appear, now that my system is fixed. However, before I discovered the fix content assist took at least 10-12 seconds to work! If you are having the same issue that I did, you can check out the post that helped me out here, or just follow the directions below which worked on my Ubuntu Jaunty 9.04 system.

From a terminal window:
sudo apt-get install eclipse-cdt sun-java6-jdk
sudo update-java-alternatives -s java-6-sun
sudo -b gedit /etc/jvm

When gedit opens up the /etc/jvm file, insert the following line at the top:
/usr/lib/jvm/java-6-sun

From a terminal window:
sudo -b gedit /etc/eclipse/java_home

When gedit opens up the /etc/eclipse/java_home file, insert the following line at the top:
/usr/lib/jvm/java-6-sun

If you have lots of RAM you can even play around with adjusting the heap size available to Eclipse. I’d suggest you read the original article here which talks more about it.