PDA

View Full Version : help: build 32-bit OpenGL apps on 64-bit ubuntu 12.04



bootstrap
06-07-2012, 09:55 PM
I just replaced my 64-bit ubuntu 10.04 LTS system of the past 2 years with a new fresh-install 64-bit ubuntu 12.04 LTS system. Actually it's just a new disk drive on the same computer, but that should be irrelevant.

I was developing a 3D engine on the old installation with the codeblocks IDE on top of the usual suspects (gcc/gdb/etc). One of the last things I did was to get the 64-bit version of the 3D engine working (had to write 64-bit SIMD/AVX/ymm assembly language versions of my 32-bit SIMD/SSE3/xmm maxtrix/vector/transformation routines).

After setting up my new system, installing codeblocks and installing the packages I needed, I was able to compile/link/execute the 64-bit version of my engine. Yeah!

However, I am unable to make the 32-bit versions compile and link, and can't figure out what to do the make this work. The build errors reported are:

#1: fatal error: <glibconfig.h> - file not found
- i provisionally "solved" this one by adding the following compiler search path for the 32-bit projects:
/usr/lib/x86_64-linux-gnu/glib-2.0/include
- this path seems totally bogus, but that's the only place on my system the glibconfig.h file exists

Given the above bogus "patch" (what's it doing inside a "lib" subdirectory, and also a 64-bit one at that?), it was able to compile, but then I got the following link errors.

#2: ld : cannot find -lX11
#3: ld : cannot find -lcairo
#4: ld : cannot find -lpango
#5: ld : cannot find -lfreetype
#6: ld : cannot find -lfmodex

----------

I thought I could maybe fix these link problem by installing the following packages (with the "ubuntu software center" application):
- libglib2.0-dev:i386
- zlib1g-dev:i386
- libcairo2-dev:i386
- libpango1.0-dev:i386
- libfreetype6-dev:i386

However, when I said "install", the application generated a warning dialog with this message:
If you install <item-from-above-list>, future updates will not include new items in the Ubuntu desktop system set. Are you sure you want to continue?

The list was about 200 items long and included fundamental packages, including:
- install packages using the apt protocol - gtk+ frontend
- install packages using the apt protocol - common data
- build-essentials
- deja-dup
- g++
- g++-multilib
- gcc
- gcc-multilib
- gdb
- gedit
- gimp
- ... and literally 100~200 more packages !!!

Needless to say, I canceled out rather than trashing my installation!
----------

The bottom line is... how do I compile 32-bit versions of my engine in 64-bit ubuntu 12.04 ???

Are "external packages" like fmodex (not supported by the "ubuntu software center") handled differently?

================================================== ================
##### HARDWARE #####
MBx = gigabyte 990FXA-UD7
CPU = AMD FX-8150 8-core bulldozer
RAM = 8GB DDR3 in 2 matched modules
GPU = nvidia GTX-580
HDD = 250GB seagate SATA2 @7200rpm --- 64-bit ubuntu 12.04 boot disk
HDD = 250GB seagate SATA2 @7200rpm --- alternate ubuntu 12.04 boot disk and backups
HDD = 1024GB seagate SATA3 @7200rpm --- backup drive
HDD = 3072GB seagate SATA3 @7200rpm --- backup drive
HDD = 2048GB seagate external USB drive --- backup drive
DVD = TSSTcorp CDDVDW SH-S223B --- CD/DVD burner (SATA2)
DVD = HL-DT-ST BD-RE WH12LS38 --- CD/DVD/bluray burner (SATA2)

##### SOFTWARE #####
64-bit ubuntu 12.04 LTS
codeblocks IDE
gcc
g++
gdb
gcc-multilib
g++-multilib
build-essential
libwxgtk2.8-0
libwxgtk2.8-dev
wx2.8-doc
wx-com
libx11-6
libx11-dev
libx11-doc
libxext-dev
mesa-utils (glxinfo, glxgears, glxheads, glxdemo)
zlib1g-dev
libcairo2
libcairo2-dev
libgcairo2-doc
libpango1.0-0
libpango1.0-dev
libpango1.0-doc
libfreetype6
libfreetype6-dev
NVIDIA-Linux-x86_64-295.53.run
- download and execute with --extract-only option to create directory with include and library files
- copy all .h files to directory /usr/include/GL (gl.h, glx.h, glext.h, glxext.h)
glew-1.7.0.zip
- download and extract to directory to access .h and .c files
- copy all .h files to directory /usr/include/GL (glew.h, glxew.h, wglew.h)
- copy 3 .c files into project directory (glew.c, glewinfo.c, visualinfo.c)
fmodapi44008linux64.tar.gz
- download and extract to directory to access .h and .so files
- copy all .h files to directory /usr/include/fmodex
- copy all .so files to directory /usr/lib

##### APPLICATION #####
requires X11 - xlib.h
requires GL/GLX - gl.h, glext.h, glx.h, glxext.h
requires GLEW - glew.h, glew.c, etc...
requires cairo library
requires pango library
requires freetype library
requires fmodex - fmodex.h
requires standard c libraries
no SDL or other frameworks

bootstrap
06-08-2012, 03:10 PM
An update. I was told to NOT install the ia32-libs package, because "multiarch" and "multilib" now takes care of everything. Ehhhhh... not everything. After I installed the ia32-libs package and make a couple tweaks, codeblocks was able to compile/link/execute both 32-bit and 64-bit versions of my 3D engine. Hurrah!

thokra
06-09-2012, 06:53 AM
Did you tell g++ to compile for 32-bit arch? Add -m32 to the command line.

bootstrap
06-09-2012, 05:00 PM
Did you tell g++ to compile for 32-bit arch? Add -m32 to the command line.
Thanks for the idea. But yes, the -m32 and -m64 settings to compiler and linker have always been in the 32-bit and 64-bit properties of this program.