Saturday, October 16, 2010

How to compile VTBuilder in Ubuntu Lucid

VTBuilder with ETOPO data on Ubuntu Lucid


I use VTBuilder as a GIS data converter and preprocessor for creating terrain for OpenSim. Unfortunately there is not Ubuntu package for it and I had to use the windows version. I really don't like to move to another computer or reboot in the middle of a creative experience so I want VTBuilder in my Ubuntu box. But the "General Unix Build Instructions for the VTP Software" at http://www.vterrain.org/Distrib/unix_build.html did not work for my Ubuntu Lucid. So after two sleepless nights I was able to hack the makefiles and successfully ran VTBuilder in Lucid. I still do not know how stable this is or what will work and not work.

Warning: The following information is for people who knows how to compile software from source files in Ubuntu GNU/Linux. It is for an amd64 flavor only. I have not tested it on a 32 bit flavor and anyone wanting to do so, may need to modify the Make.defs file in the vtp4lucid files I've included in this post.

I assume you have an amd64 Ubuntu Lucid box with all the developer files for compiling software e.g. gcc, make, patch, x11proto dev files, etc.

**Files needed**


Source code of the Virtual Terrain Project (VTP) http://www.vterrain.org/
VTBuilder is a tool in this suite.

Get it via svn from http://code.google.com/p/vtp/source/checkout

**Dependencies**

Most of the dependencies are in the repositories. Issue the following:

sudo apt-get install openscenegraph openscenegraph56 libgdal1-1.6.0 
libgdal1-dev libproj-dev proj proj-data zlib1g-dev zlib1g-dbg netcdf-bin 
libnetcdf-dev libnetcdf4 netcdf-dbg tcsh libwxgtk2.8-0 libwxgtk2.8-dev 
libwxgtk2.8-dbg bzip2 libbz2-dev libbz2-1.0 libtiff4-dev  libpng12-0 
libpng12-dev libjpeg62-dbg libjpeg62 libjpeg62-dev libglut3-dev libglut3 
freeglut3 freeglut3-dev freeglut3-dbg glutg3 glutg3-dev libcurl3-gnutls 
libcurl4-gnutls-dev

I may be missing something so check again if errors are encountered during compilation. Some of these files may not be needed but I really do not know, so I probably included more than necessary.

There are three libraries not in the repositories that needs to be built first. These are squish, libMini and Quikgrid. I failed to compile quikgrid so it is not included here.

**Squish**

Fortunately there is a ppa of the squish libraries here https://launchpad.net/~kervala/+archive/ppa. The list of files needed are the following.

libsquish1_1.10.26~lucid0_amd64.deb
libsquish-dev_1.10.26~lucid0_amd64.deb
libsquish1-dbg_1.10.26~lucid0_amd64.deb
squish-extra-dbg_1.10.26~lucid0_amd64.deb
squish-extra_1.10.26~lucid0_amd64.deb

I have included this in the vtp4lucid tools below. Install them with Gdebi starting with libsquish1_1.10.26~lucid0_amd64.deb. Or cd to the folder where you extracted the deb files and issue the following command in a terminal:

sudo dpkg -i *.deb

**LibMini**

The Mini library source code can be downloaded here http://stereofx.org/download. I also included this in the vtp4lucid tools. It's very easy to build and install. You will need tcsh for this one.

1. Open a terminal (it would be bash)
2. type tcsh (you're now in tcsh)
3. cd to the mini source code folder
4. issue the following command

sudo ./build.sh install

It will install the following:

/usr/local/lib/libMini.a
/usr/local/include/mini  folder
/usr/share/mini folder

5. type exit and you will be back in bash

**VTP4Lucid tools**

Download: http://www.mediafire.com/file/enb4ioqdgnxq6dc/vtp4lucid.tar.gz (2.76 MB)

Download the modified makefiles and other needed files including mini and squish at . Extract in your vtp folder. It should replace Make.defs in the root of the vtp folder and Makefiles in the TerrainApps folder. It will also put Data/Culture and Data/WorldMap folders in TerrainApps. These are needed by VTBuilder but not included in the source code.

The Makefiles were modified by changing lgdal to lgdal1.6.0 because it could not find the gdal library in Lucid. The Make.defs file library paths were modified for Lucid.


**Building VTP**

A. Compiling TerrainSDK

1. open a terminal and issue the following commands

export GDAL_DATA=/usr/share/gdal16
export PROJ_LIB=/usr/share/proj

2. cd to TerrainSDK folder
3. type

sudo make install

it will install libraries and header files in /usr/local/lib and /usr/local/include respectively

4. after it successfully compiled issue the following commands in the terminal

sudo export LD_LIBRARY_PATH=/usr/local/lib:/home/dilis/OPT/vtp/TerrainSDK/vtdata:/home/dilis/OPT/vtp/TerrainSDK/vtlib/vtosg:/home/dilis/OPT/vtp/TerrainSDK/xmlhelper:/home/dilis/OPT/vtp/TerrainSDK/vtui:/home/dilis/OPT/vtp/TerrainSDK/unzip:/home/dilis/OPT/vtp/TerrainSDK/minidata

Make sure to replace the path of TerrainSDK above with your setup. There is a need to make the environment variables persistent but I forgot how :-( while doing this build. This may help https://help.ubuntu.com/community/EnvironmentVariables#System-wide%20environment%20variables.


B. Building VTBuilder

You may build VTBuilder alone or the entire VTP suite. I don't know what Enviro and CManager is for. VTBuilder and Enviro worked but CManager did not. When I ran it, it spew out the following error:

Warning: winsize 0 0
Error: OpenGL version test failed, requires valid graphics context.
The program 'CManager' received an X Window System error.
This probably reflects a bug in the program.
The error was 'GLXBadDrawable'.
  (Details: serial 816 error_code 130 request_code 128 minor_code 11)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

1. VTBuilder

a. cd to TerrainApps folder
b. issue the following command in a terminal

sudo make VTBuilder

c. cd to the VTBuilder folder
d. run VTBuilder with

./VTBuilder

2. VTP

To build the VTP suite

a. cd to TerrainApps folder
b. issue the following command in a terminal

sudo make

c. cd to the Cmake, Enviro, and VTBuilder folder
d. run the apps in the same manner as above

Update: SETTING ENVIRONMENT VARIABLES SYSTEM WIDE

1. Put this in /etc/environment file after PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

GDAL_DATA="/usr/share/gdal16"
PROJ_LIB="/usr/share/proj"


2. LD_LIBRARY_PATH

a) create /etc/ld.so.conf.d/*.conf e.g.
sudo touch /etc/ld.so.conf.d/*.conf

b) open *.conf in gedit
sudo gedit /etc/ld.so.conf.d/*.conf

c) enter the following in *.conf

/home/dilis/OPT/vtp/TerrainSDK/vtdata
/home/dilis/OPT/vtp/TerrainSDK/vtlib/vtosg
/home/dilis/OPT/vtp/TerrainSDK/xmlhelper
/home/dilis/OPT/vtp/TerrainSDK/vtui
/home/dilis/OPT/vtp/TerrainSDK/unzip
/home/dilis/OPT/vtp/TerrainSDK/minidata

d) run
ldconfig -v
in a terminal

that's all there is to it. Now you can double click on VTBuilder and it will open.



Have fun,

Roel Cantada
http://matangdilis.blogspot.com

update: April 1, 2011, Enviro screenshots. Enviro is looking for a terrain, but I don't know what it is. As you can see the earth view shows only a blank sphere.


5 comments:

Anonymous said...

Hello,
VTBuilder work fine, but when i try to compile Enviro.
wx/canvas.o: In function `GraphicsWindowWX::CloseOsgContext()':
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:51: undefined reference to `osgGA::EventQueue::closeWindow(double)'
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:53: undefined reference to `typeinfo for osgViewer::View'
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:51: undefined reference to `osgGA::EventQueue::closeWindow(double)'
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:53: undefined reference to `typeinfo for osgViewer::View'
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:51: undefined reference to `osgGA::EventQueue::closeWindow(double)'
/usr/local/src/vtp/TerrainSDK/vtui/GraphicsWindowWX.h:53: undefined reference to `typeinfo for osgViewer::View'

matangdilis said...

Those debug messages appear to refer to openscenegraph. If you have installed openscenegraph and openscenegraph56 then i can only speculate that some other dependency is missing.

Anonymous said...

Dear matangdilis, thank you for these extensive instructions. Could you please share your compiled package with us? I am not familiar with compiling on ubuntu :-(

matangdilis said...

Dear Anonymous,

Unfortunately I do not know how to make deb packages. I can only hope that someone knowledgeable in packaging would try to create a ppa of vtp.

I have added a screenshot of Enviro above. It is not very useful to me as it is looking for a terrain I do not.

matangdilis said...

that should be "enviro is looking for a terrain i do not have".

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.