Building OpenSG in Ubuntu / Linux

29 May

Grab OpenSG 1.8.X

For debian based systems, we can use the ppa as documented here (http://www.opensg.org/wiki/Releases)

deb     http://ppa.launchpad.net/opensg/ubuntu gutsy main restricted universe multiverse

deb-src http://ppa.launchpad.net/opensg/ubuntu gutsy main restricted universe multiverse

To 9.10 (karmic koala) the package can be found here (https://launchpad.net/ubuntu/+source/opensg), the simplest way to add it is by:

> sudo add-apt-repository ppa:opensg

OpenSG 1.8.X can be build in Linux either by configure (http://www.opensg.org/wiki/BuildLinuxAutoTools) or by GCC and scons (http://www.opensg.org/wiki/BuildLinuxScons).
(if you are really insane, you can compile OpenSG – note: it took 1/1h30 hours on my netbook… full scale build. There’s a parallel build you you have a multicore/manycores)If you wish to compile OpenSG from source, checkout from cvs first using:

cvs -d:pserver:anonymous@opensg.cvs.sourceforge.net:/cvsroot/opensg login
cvs -z3 -d:pserver:anonymous@opensg.cvs.sourceforge.net:/cvsroot/opensg co -P modulename

(where modulesname is OpenSG)

Then, make sure you have build-essential (basic build package for Debian Linux).

And they recommend instaling this (package dependencies):
sudo apt-get install g++ libglut3-dev zlib1g-dev bison flex libjpeg62-dev libpng12-dev libtiff4-dev libqt4-dev
The glut is essential, and I’ve also installed support for both qt3 and qt4, by locating manually the include directories in my system (use find and locate them, if it complains try different directories)

Easy install (via Synaptic or apt-get)

The easiest way is by adding the ppa repository as shown above, an then simply use your preferred way to add new software. On Ubuntu I like to use synaptic (which is a graphical frontend and works nice for newbie users). Type opensg in the search bo and install what you need (I installed everything because I’m in developing stage, glut related packages are important), here’s a screenshot:

Screenshot(larger version by clicking here or in the image)

Building the source code

Go to the OpenSG source folder and type:

./configure --enable-glut --enable-jpg --enable-png --enable-qt3 --with-qt3=/usr/lib --enable-qt4 --with-qt4=/usr/share/qt4

./make >> make.log

sudo ./make install >> make-install.log

Make in a Compaq Mini only compiling with one core, 1.6ghz Atom cpu, took:

real    96m52.034s
user    82m28.065s
sys    7m13.607s(I’d recommend going to do something or work in a different core or computer)

Checking the installation

In theory, you’re done. But now I’ll present a way to test if your OpenSG installation was successful:

  • Check if GLUT support succedded (this is crucial!), for that we use osg-config which is a small executable that checks OpenSG related issues:
> osg-config --libs GLUT
-g -L/usr/local/lib/dbg -lOSGWindowGLUT -lOSGSystem -lOSGBase
-ljpeg -lpng -lz -lglut -lGLU -lGL -lXmu -lXi -lXt -lX11 -lpthread -ldl -lm -L/usr/X11R6/lib

And as you see, GLUT is configured with OpenSG (hooray!) – otherwise it would give a warning and say that GLUT was not configured.

  • Go to the Tutorial folder (in OpenSG/Tutorial) to test a demo:
./make
If demos are running well, you can get a pretty Thai Fighter in 18opengl_slave.cpp – take a look at the image below.
Screenshot-1

Typical FAQ, when compiling the Tutorials

Now you can get all sort of issues, so I’ll post them here:
  • Cannot find osg-config or OSG root directory:
Edit the makefile and correct the OSG_ROOT variable with your root folder for OSG, mine was /usr/local. Also the variable OSGCONFIG should point to OSGCONFIG := /usr/local/bin/osg-config
  • Cannot find Glut stuff, (c++ errors) – check again if GLUT support was installed. This is necessary! (see previous paragraphs on how to check with osg-config), If check fails you must build it with GLUT enabled.
  • Ld (linker) complains that he cannot find dynamic libraries like libOSGWindowGLUT.so (or libOSGWindowX.so, libOSGBase.so, etc..):
This is very easy, and common, what’s happening is your program compiles well but then when you launch it, the system cannot find the libs. Just copy them to the system folder that holds your libraries, i.e.:
> sudo cp /usr/local/lib/dbg/* /usr/lib

A more extended FAQ (with other issues)

  • If you’re not getting it working, you can try to change makefile a bit (for me it was changing LIBTYPE ?= dbg, instead of opt) to compile the tutorials. Of course if you build OpenSG with either opt and dbg, both works.
  • To check glut, simple GL application, without OpenSG: > gcc cube.c -o cube -lglut; this should build a cube application using this source file. Test it.
Advertisements

5 Responses to “Building OpenSG in Ubuntu / Linux”

  1. C.A. November 9, 2010 at 5:36 am #

    I’m deeply in love with every single piece of information you post here.
    I’ll b back often to read more updates…

    I am very much impressed

    Thanks…………

  2. M.Oe. March 6, 2011 at 9:52 am #

    Hi!

    Could you explain how to install on “Maverick Meerkat”? After adding repositories via “sudo add-apt-repository ppa:opensg” I cannot find anything in synaptic by searching for “opensg”.

    Thanks in advance for your help!!

  3. Ani Sunny March 24, 2011 at 6:10 am #

    Hey!! The information was really useful in checking if I had installed openSg properly. The installation seems to be fine but while compiling the Tutorial the program 18opengl_slave.cpp seems to be showing errors like the following:
    ani@anilap:~/OpenSG/Tutorials$ make
    g++ -D_GNU_SOURCE -DQT_CLEAN_NAMESPACE -DOSG_WITH_GLUT -DOSG_WITH_TIF -DOSG_WITH_JPG -DOSG_WITH_PNG -D_OSG_HAVE_CONFIGURED_H_ -DQT_NO_XINERAMA -DQT_NO_XRENDER -DQT_NO_XFTFREETYPE -DQT_NO_XKB -DQT_NO_SM_SUPPORT -DQT_NO_IMAGEIO_MNG -DQT_NO_IMAGEIO_JPEG -DQT_NO_STYLE_AQUA -DQT_NO_STYLE_MAC -DQT_NO_STYLE_INTERLACE -DQT_NO_STYLE_COMPACT -ansi -use_readonly_const -ftemplate-depth-100 -g -DOSG_DEBUG -DOSG_WITH_GLUT -DOSG_WITH_TIF -DOSG_WITH_JPG -DOSG_WITH_PNG -I/usr/local/include 18opengl_slave.cpp -g -L/usr/local/lib/dbg -lOSGWindowGLUT -lOSGWindowX -lOSGSystem -lOSGBase -ltiff -ljpeg -lpng -lz -lglut -lGLU -lGL -lXmu -lXi -lXt -lX11 -lpthread -ldl -lm -L/usr/X11R6/lib -o 18opengl_slave
    In file included from /usr/include/c++/4.4/ext/hash_map:60,
    from /usr/local/include/OpenSG/OSGWindow.h:53,
    from /usr/local/include/OpenSG/OSGGeometry.h:48,
    from /usr/local/include/OpenSG/OSGSimpleGeometry.h:49,
    from 18opengl_slave.cpp:21:
    /usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
    18opengl_slave.cpp:70: error: ‘’ has incomplete type
    18opengl_slave.cpp:70: error: invalid use of ‘GLvoid’
    18opengl_slave.cpp: In function ‘GLvoid InitGL(GLsizei, GLsizei)’:
    18opengl_slave.cpp:70: error: too few arguments to function ‘GLvoid LoadGLTextures()’
    18opengl_slave.cpp:92: error: at this point in file
    18opengl_slave.cpp: At global scope:
    18opengl_slave.cpp:310: error: ‘’ has incomplete type
    18opengl_slave.cpp:310: error: invalid use of ‘GLvoid’
    18opengl_slave.cpp: In function ‘int main(int, char**)’:
    18opengl_slave.cpp:486: error: invalid conversion from ‘GLvoid (*)()’ to ‘void (*)()’
    18opengl_slave.cpp:486: error: initializing argument 1 of ‘void glutDisplayFunc(void (*)())’
    make: *** [18opengl_slave] Error 1

    I am unable to figure out the solution. Actually I am at a loss since I’ve just started with OpenSG and rendering.
    I would be really grateful if someone could help me.

    • pedrolopesresearch March 24, 2011 at 12:33 pm #

      That file is an example or the openSG core?

      If it an example remove it for now and analyse it later.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: