Compiling TGE 1.5.2 on Ubuntu Karmic (9.10)
by Jamin Collins · in Torque Game Engine · 02/10/2010 (2:38 pm) · 10 replies
Just thought I'd post this for anyone having trouble compiling TGE v1.5.2 under Ubuntu Karmic. From what I can tell, there are three patches that need to be applied to the source. These are:
OpenAL function patch:
GCC compiler version patch:
OpenAL Soft device initialization patch:
With these patches in place, the necessary build dependencies need to be installed:
Then you should be able to compile:
OpenAL function patch:
diff -Naur Torque1.5.2-Linux.orig/lib/openal/LINUX/al/alc_func.h Torque1.5.2-Linux/lib/openal/LINUX/al/alc_func.h --- Torque1.5.2-Linux.orig/lib/openal/LINUX/al/alc_func.h 2007-05-11 16:58:29.000000000 -0400 +++ Torque1.5.2-Linux/lib/openal/LINUX/al/alc_func.h 2008-06-23 08:55:15.000000000 -0400 @@ -8,7 +8,7 @@ AL_FUNCTION(ALCcontext*, alcCreateContext, (ALCdevice *device,ALCint *attrList), return NULL; ) AL_FUNCTION(ALCboolean, alcMakeContextCurrent, (ALCcontext *context), return AL_FALSE; ) AL_FUNCTION(ALCvoid, alcProcessContext, (ALCcontext *context), return; ) -AL_FUNCTION(ALCcontext*, alcGetCurrentContext, (ALCvoid), return NULL; ) +AL_FUNCTION(ALCcontext*, alcGetCurrentContext, (void), return NULL; ) AL_FUNCTION(ALCdevice*, alcGetContextsDevice, (ALCcontext *context), return NULL; ) AL_FUNCTION(ALCvoid, alcSuspendContext, (ALCcontext *context), return; ) AL_FUNCTION(ALCvoid, alcDestroyContext, (ALCcontext *context), return; ) diff -Naur Torque1.5.2-Linux.orig/lib/openal/LINUX/al/al_func.h Torque1.5.2-Linux/lib/openal/LINUX/al/al_func.h --- Torque1.5.2-Linux.orig/lib/openal/LINUX/al/al_func.h 2007-05-11 16:58:29.000000000 -0400 +++ Torque1.5.2-Linux/lib/openal/LINUX/al/al_func.h 2008-06-23 08:55:32.000000000 -0400 @@ -15,7 +15,7 @@ AL_FUNCTION(ALvoid, alGetDoublev, ( ALenum param, ALdouble* data ), return; ) AL_FUNCTION(ALubyte*, alGetString, ( ALenum param ), return NULL; ) -AL_FUNCTION(ALenum, alGetError, ( ALvoid ), return AL_INVALID_VALUE; ) +AL_FUNCTION(ALenum, alGetError, ( void ), return AL_INVALID_VALUE; ) AL_FUNCTION(ALboolean, alIsExtensionPresent, ( ALubyte* fname ), return AL_FALSE; ) AL_FUNCTION(ALvoid*, alGetProcAddress, ( ALubyte* fname ), return NULL; ) AL_FUNCTION(ALenum, alGetEnumValue, ( ALubyte* ename ), return AL_INVALID_ENUM; )
GCC compiler version patch:
diff -Naur Torque1.5.2-Linux.orig/mk/conf.GCC4.mk Torque1.5.2-Linux/mk/conf.GCC4.mk --- Torque1.5.2-Linux.orig/mk/conf.GCC4.mk 2007-05-11 20:58:32.000000000 +0000 +++ Torque1.5.2-Linux/mk/conf.GCC4.mk 2008-11-17 01:08:31.000000000 +0000 @@ -1,8 +1,8 @@ include ../mk/conf.GCC.mk -COMPILER.c =gcc +COMPILER.c =gcc-4.2 # -Wno-invalid-offsetof is only valid for g++ compilation, had to remove it from the CFLAGS variable seeing that we # pass CFLAGS to both gcc and g++ -COMPILER.cc =g++ -Wno-invalid-offsetof +COMPILER.cc =g++-4.2 -Wno-invalid-offsetof CFLAGS += -mtune=i686
OpenAL Soft device initialization patch:
diff -Naur Torque1.5.2-Linux.orig/engine/audio/audio.cc Torque1.5.2-Linux/engine/audio/audio.cc
--- Torque1.5.2-Linux.orig/engine/audio/audio.cc 2007-05-31 16:56:56.000000000 -0400
+++ Torque1.5.2-Linux/engine/audio/audio.cc 2008-11-19 18:25:32.000000000 -0500
@@ -2371,16 +2371,7 @@
return false;
// Open a device
-#ifdef TORQUE_OS_LINUX
- const char* deviceSpecifier =
- Con::getVariable("Pref::Unix::OpenALSpecifier");
- if (dStrlen(deviceSpecifier) == 0)
- // use SDL for audio output by default
- deviceSpecifier = "'((devices '(sdl)))";
- mDevice = (ALCdevice *)alcOpenDevice((ALubyte*)deviceSpecifier);
-#else
mDevice = (ALCdevice *)alcOpenDevice((ALubyte*)NULL);
-#endif
if (mDevice == (ALCdevice *)NULL)
return false;With these patches in place, the necessary build dependencies need to be installed:
sudo apt-get -y install build-essential nasm mesa-utils mesa-common-dev libsdl1.2-dev libalut-dev g++-4.2-multilib libxft-dev
Then you should be able to compile:
make -f mk/configure.mk OS=LINUX COMPILER=GCC4 BUILD=RELEASE make
About the author
#2
*Note: I'm a complete newb to makefiles. I can compile individual C++ files into applications, but I really don't understand most of the build process in Linux.
EDIT:
Okay, so I got around that error by grepping all the mk/ files for -mcpu :P. I had to change a line in conf.UNIX.mk to:
10/19/2010 (11:47 pm)
Any chance this will work on 10.04? I'm using g++-4.4, so I made the necessary changes to conf.GCC4.mk, but I get the following:daniel@Daniel-PC:/media/Common/Downloads/Torque1.5.2-Linux$ make --> Compiling lpng/png.c /bin/sh: freetype-config: not found `-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead. lpng/png.c:1: error: CPU you selected does not support x86-64 instruction set make[1]: *** [out.GCC4.RELEASE/lpng/png.obj] Error 1 make: *** [default] Error 2 daniel@Daniel-PC:/media/Common/Downloads/Torque1.5.2-Linux$Also, g++-4.2-multilib couldn't be found, so I removed it from the list and all the other packages seemed to install fine.
*Note: I'm a complete newb to makefiles. I can compile individual C++ files into applications, but I really don't understand most of the build process in Linux.
EDIT:
Okay, so I got around that error by grepping all the mk/ files for -mcpu :P. I had to change a line in conf.UNIX.mk to:
CFLAGS.GENERAL = -DUSE_FILE_REDIRECT -I/usr/X11R6/include/ -MD -march=x86-64
`freetype-config --cflags` -mtune=x86-64 -ffast-math -pipeThe libraries started compiling, but eventually this happens:Creating library out.GCC4.RELEASE/lungif.a
--> Compiling audio/audio.cc
In file included from ./platform/types.h:70,
from ./platform/platform.h:14,
from ./platform/platformAudio.h:10,
from ./audio/audio.h:10,
from audio/audio.cc:6:
./platform/types.gcc.h:92:4: error: #error "GCC: Unsupported Target CPU"
In file included from ./platform/platformAudio.h:10,
from ./audio/audio.h:10,
from audio/audio.cc:6:
./platform/platform.h:204:2: error: #error "Endian define not set"
In file included from ./platform/platformAudio.h:10,
from ./audio/audio.h:10,
from audio/audio.cc:6:
./platform/platform.h:556: error: ‘operator new’ takes type ‘size_t’ (‘long unsigned int’) as first parameter
./platform/platform.h:577: error: ‘operator new’ takes type ‘size_t’ (‘long unsigned int’) as first parameter
./platform/platform.h:578: error: ‘operator new’ takes type ‘size_t’ (‘long unsigned int’) as first parameter
In file included from ./core/fileStream.h:13,
from ./core/resManager.h:20,
from ./audio/audioBuffer.h:16,
from ./audio/audioDataBlock.h:13,
from ./audio/audio.h:13,
from audio/audio.cc:6:
./core/stream.h: In member function ‘bool Stream::write(S16)’:
./core/stream.h:147: error: ‘convertHostToLEndian’ was not declared in this scope
./core/stream.h: In member function ‘bool Stream::write(S32)’:
...
Lots more like this
...
./core/stream.h:161: error: ‘convertLEndianToHost’ was not declared in this scope
./core/stream.h: In member function ‘bool Stream::read(F64*)’:
./core/stream.h:162: error: ‘convertLEndianToHost’ was not declared in this scope
In file included from ./sim/sceneObject.h:31,
from ./game/gameBase.h:10,
from ./game/shapeBase.h:10,
from ./game/gameConnection.h:13,
from audio/audio.cc:11:
./lightingSystem/sgLightManager.h: In static member function ‘static hash_multimap<unsigned int, sgInteriorDynamicLightingCache::data>* sgInteriorDynamicLightingCache::sgFindCacheEntry(void*, void*, LightInfo*)’:
./lightingSystem/sgLightManager.h:334: error: cast from ‘void*’ to ‘U32’ loses precision
./lightingSystem/sgLightManager.h:336: error: cast from ‘LightInfo*’ to ‘U32’ loses precision
./lightingSystem/sgLightManager.h: In static member function ‘static hash_multimap<unsigned int, sgDTSDynamicLightingCache::data>* sgDTSDynamicLightingCache::sgFindCacheEntry(void*, LightInfo*)’:
./lightingSystem/sgLightManager.h:374: error: cast from ‘void*’ to ‘U32’ loses precision
./lightingSystem/sgLightManager.h:376: error: cast from ‘LightInfo*’ to ‘U32’ loses precision
In file included from ./game/shapeBase.h:35,
from ./game/gameConnection.h:13,
from audio/audio.cc:11:
./lightingSystem/sgObjectShadows.h: In member function ‘U32 sgObjectShadows::sgLightToHash(LightInfo*)’:
./lightingSystem/sgObjectShadows.h:49: error: cast from ‘LightInfo*’ to ‘U32’ loses precision
make[1]: *** [out.GCC4.RELEASE/audio/audio.obj] Error 1
make: *** [default] Error 2
#3
It sounds like you're trying to compile the source on a 64-bit installation. The TGE source is not 64-bit native and does not compile on a 64-bit system without being told to compile as a 32-bit binary, at least not as far as I know or have been successful with.
Additionally, you indicate that you're trying to compile with g++-4.4, I found I had to go back to 4.1. With it and the following patch, I was able to build successfully:
My configure command:
10/20/2010 (3:29 am)
The important bit is here:error: CPU you selected does not support x86-64 instruction set
It sounds like you're trying to compile the source on a 64-bit installation. The TGE source is not 64-bit native and does not compile on a 64-bit system without being told to compile as a 32-bit binary, at least not as far as I know or have been successful with.
Additionally, you indicate that you're trying to compile with g++-4.4, I found I had to go back to 4.1. With it and the following patch, I was able to build successfully:
diff -Naur Torque1.5.2-Linux.orig/mk/conf.GCC4.1.LINUX.mk Torque1.5.2-Linux/mk/conf.GCC4.1.LINUX.mk --- Torque1.5.2-Linux.orig/mk/conf.GCC4.1.LINUX.mk 1969-12-31 17:00:00.000000000 -0700 +++ Torque1.5.2-Linux/mk/conf.GCC4.1.LINUX.mk 2010-07-12 10:30:07.009949000 -0600 @@ -0,0 +1,6 @@ +include ../mk/conf.UNIX.mk + +# any setting in conf.UNIX.mk can be overridden here. compiler name +# is commonly overridden, since it varies depending on the distro. +#COMPILER.c =gcc +#COMPILER.cc =g++ diff -Naur Torque1.5.2-Linux.orig/mk/conf.GCC4.1.mk Torque1.5.2-Linux/mk/conf.GCC4.1.mk --- Torque1.5.2-Linux.orig/mk/conf.GCC4.1.mk 1969-12-31 17:00:00.000000000 -0700 +++ Torque1.5.2-Linux/mk/conf.GCC4.1.mk 2010-07-12 10:30:42.459949001 -0600 @@ -0,0 +1,8 @@ +include ../mk/conf.GCC.mk + +COMPILER.c =gcc-4.1 +# -Wno-invalid-offsetof is only valid for g++ compilation, had to remove it from the CFLAGS variable seeing that we +# pass CFLAGS to both gcc and g++ +COMPILER.cc =g++-4.1 -Wno-invalid-offsetof + +CFLAGS += -mtune=i686 diff -Naur Torque1.5.2-Linux.orig/mk/conf.GCC4.2.LINUX.mk Torque1.5.2-Linux/mk/conf.GCC4.2.LINUX.mk --- Torque1.5.2-Linux.orig/mk/conf.GCC4.2.LINUX.mk 1969-12-31 17:00:00.000000000 -0700 +++ Torque1.5.2-Linux/mk/conf.GCC4.2.LINUX.mk 2010-07-12 10:30:19.889949000 -0600 @@ -0,0 +1,6 @@ +include ../mk/conf.UNIX.mk + +# any setting in conf.UNIX.mk can be overridden here. compiler name +# is commonly overridden, since it varies depending on the distro. +#COMPILER.c =gcc +#COMPILER.cc =g++ diff -Naur Torque1.5.2-Linux.orig/mk/conf.GCC4.2.mk Torque1.5.2-Linux/mk/conf.GCC4.2.mk --- Torque1.5.2-Linux.orig/mk/conf.GCC4.2.mk 1969-12-31 17:00:00.000000000 -0700 +++ Torque1.5.2-Linux/mk/conf.GCC4.2.mk 2010-07-12 10:30:54.499949001 -0600 @@ -0,0 +1,8 @@ +include ../mk/conf.GCC.mk + +COMPILER.c =gcc-4.2 +# -Wno-invalid-offsetof is only valid for g++ compilation, had to remove it from the CFLAGS variable seeing that we +# pass CFLAGS to both gcc and g++ +COMPILER.cc =g++-4.2 -Wno-invalid-offsetof + +CFLAGS += -mtune=i686 diff -Naur Torque1.5.2-Linux.orig/mk/configure.mk Torque1.5.2-Linux/mk/configure.mk --- Torque1.5.2-Linux.orig/mk/configure.mk 2007-05-11 14:58:32.000000000 -0600 +++ Torque1.5.2-Linux/mk/configure.mk 2010-07-12 10:22:40.639949000 -0600 @@ -1,5 +1,5 @@ -COMPILER_OPTIONS=CW6 VC6 GCC2 GCC3 GCC3.4 GCC4 +COMPILER_OPTIONS=CW6 VC6 GCC2 GCC3 GCC3.4 GCC4 GCC4.1 GCC4.2 BUILD_OPTIONS=DEBUG RELEASE OS_OPTIONS=WIN32 BEOS LINUX OpenBSD FreeBSD Solaris diff -Naur Torque1.5.2-Linux.orig/mk/conf.UNIX.mk Torque1.5.2-Linux/mk/conf.UNIX.mk --- Torque1.5.2-Linux.orig/mk/conf.UNIX.mk 2007-05-11 14:58:32.000000000 -0600 +++ Torque1.5.2-Linux/mk/conf.UNIX.mk 2010-07-12 10:18:45.779949001 -0600 @@ -39,7 +39,7 @@ # but it is disabled by default # -fno-check-new is not tested CFLAGS.GENERAL = -DUSE_FILE_REDIRECT -I/usr/X11R6/include/ -MD -march=i586 - `freetype-config --cflags` -mcpu=i686 -ffast-math -pipe + `freetype-config --cflags` -mcpu=i686 -ffast-math -pipe -m32 #-w -fno-exceptions -fno-check-new CFLAGS.RELEASE = -O2 -finline-functions -fomit-frame-pointer @@ -48,7 +48,7 @@ ASMFLAGS = -f elf -dLINUX -LFLAGS.GENERAL = +LFLAGS.GENERAL = -m32 LFLAGS.RELEASE = LFLAGS.DEBUG =
My configure command:
make -f mk/configure.mk OS=LINUX COMPILER=GCC4.1 BUILD=RELEASE
#4
But I'm still running into problems... new problems, which is a good sign, I guess :P
EDIT: Hmm, I tried installing the package again and it worked. Go figure :P. Now I'm getting up to linking! Hurrah. Apparently -lGLU cannot be found. Time for some more digging.
Specifically:
10/21/2010 (7:32 am)
Thanks! I should have mentioned I'm running 64 bit, but I never had trouble with it in Windows.But I'm still running into problems... new problems, which is a good sign, I guess :P
daniel@Daniel-PC:/media/Common/Downloads/Torque1.5.2-Linux$ make
--> Compiling lpng/png.c
In file included from /usr/include/features.h:378,
from /usr/include/stdio.h:28,
from lpng/pngconf.h:243,
from lpng/png.h:363,
from lpng/png.c:13:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make[1]: *** [out.GCC4.1.RELEASE/lpng/png.obj] Error 1
make: *** [default] Error 2I get this with both GCC4.1 and GCC4.4. I did a bit of searching which indicated that this is something to do with the standard libraries, which I have 64-bit versions of. I found somewhere indicating that I should apt-get libc6-dev-i386, but that answer seemed a little uncertain and in any case the package couldn't be found when I tried it.EDIT: Hmm, I tried installing the package again and it worked. Go figure :P. Now I'm getting up to linking! Hurrah. Apparently -lGLU cannot be found. Time for some more digging.
Specifically:
--> Linking out.GCC4.1.RELEASE/torqueDemo.bin /usr/bin/ld: skipping incompatible /usr/lib/libGLU.a when searching for -lGLU /usr/bin/ld: cannot find -lGLU collect2: ld returned 1 exit status make[1]: *** [out.GCC4.1.RELEASE/torqueDemo.bin] Error 1 make: *** [default] Error 2
#5
I've recently upgraded to maverick (as the output below indicates), but this package was installed while on 10.04 as I recall:
10/21/2010 (2:21 pm)
No uncertainty. That is indeed the package that provides the missing file.$ dpkg -S stubs-32.h libc6-dev-i386: /usr/include/gnu/stubs-32.h
I've recently upgraded to maverick (as the output below indicates), but this package was installed while on 10.04 as I recall:
$ apt-cache policy libc6-dev-i386
libc6-dev-i386:
Installed: 2.12.1-0ubuntu7
Candidate: 2.12.1-0ubuntu7
Version table:
*** 2.12.1-0ubuntu7 0
500 http://us.archive.ubuntu.com/ubuntu/ maverick-updates/main amd64 Packages
100 /var/lib/dpkg/status
2.12.1-0ubuntu6 0
500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
#6
10/21/2010 (2:29 pm)
Linking issues are going to be due to not having the 32-bit version of the libraries, since you're on a 64-bit system and telling it to compile a 32-bit version. There's not truly easy way to simply tell the system to figure out and get all the dependencies. However there is a rather nice tool for grabbing specific 32-bit packages and installing them on 64-bit Debian/Ubuntu. It's called "getlibs". A packaged version of it can be found in my PPA, here's a direct link to the deb.
#7
So with getlibs, should I be trying to get the 32-bit versions of the mesa packages? It seems that the incompatible libGLU was part of that stuff.
EDIT: Got lucky this boot and the internet is working :P. But I have no idea what to use getlibs for, and the manpage doesn't seem to be working. Solution: I'm not rebooting till I solve this :P.
I'm feeling it may be easier to just run 32-bit Ubuntu :P.
10/23/2010 (4:17 am)
Thanks! I've installed the package and I'd be much quicker at trying stuff out, but the internet is intermittent when I boot into Ubuntu... apparently the router we have at college hates me :P.So with getlibs, should I be trying to get the 32-bit versions of the mesa packages? It seems that the incompatible libGLU was part of that stuff.
EDIT: Got lucky this boot and the internet is working :P. But I have no idea what to use getlibs for, and the manpage doesn't seem to be working. Solution: I'm not rebooting till I solve this :P.
I'm feeling it may be easier to just run 32-bit Ubuntu :P.
#8
It seems to be complaining about calling the function strstr with const char* arguments. This, again, I think is related to using GCC4.4. But I can find no feasible way of actually getting an earlier version of GCC. None of the repositories seem to have install candidates earlier than GCC4.3, and even when I try to install that it can't find dependencies.
EDIT: Turned out to be a simple fix: just cast the first argument to char* manually, which is actually done in winStrings.cc. Now it can't find the -logg, -vorbis or -ltheora libraries. Uh.
EDIT: Solved by installing libogg-dev, libtheora-dev and libvorbis-dev in my chrooted environment. Now the engine compiles fine, but OpenAL is failing to initialize when I run it. Other than that everything works... woo!
12/08/2010 (8:10 am)
I think I'm nearly there. Someone advised me to create a 32-bit chroot environment to compile in, which was an interesting process in itself (here's a great guide), and seems to have nearly worked. With the above patches I can pretty much run make, and it looks to be working... till it gets to x86UNIXStrings.cc, where I get:platformX86UNIX/x86UNIXStrings.cc: In function 'char* dStrstr(const char*, const char*)': platformX86UNIX/x86UNIXStrings.cc:279: error: invalid conversion from 'const char*' to 'char*' make[1]: *** [out.GCC4.RELEASE/platformX86UNIX/x86UNIXStrings.obj] Error 1 make: *** [default] Error 2
It seems to be complaining about calling the function strstr with const char* arguments. This, again, I think is related to using GCC4.4. But I can find no feasible way of actually getting an earlier version of GCC. None of the repositories seem to have install candidates earlier than GCC4.3, and even when I try to install that it can't find dependencies.
EDIT: Turned out to be a simple fix: just cast the first argument to char* manually, which is actually done in winStrings.cc. Now it can't find the -logg, -vorbis or -ltheora libraries. Uh.
EDIT: Solved by installing libogg-dev, libtheora-dev and libvorbis-dev in my chrooted environment. Now the engine compiles fine, but OpenAL is failing to initialize when I run it. Other than that everything works... woo!
#10
07/13/2011 (5:28 pm)
I'd just like to mention that I went through this process on a 32-bit computer just now and it worked perfectly ;P. Thanks again!
Torque Owner Gary Rigg
Gary