Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Ubuntu, Allegro 4.9.9.1, GCC, PNG

Credits go to Elias and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
Ubuntu, Allegro 4.9.9.1, GCC, PNG
nzmike
Member #10,841
March 2009

Hello Allegro community,

I've recently come across Allegro and am excited to start using it however I'm having a few problems setting it up.

So my current environment is:

OS - Ubuntu 9.04 Beta
Compiler - gcc, g++
IDE - Code::Blocks
Allegro - 4.9.9.1

The steps I've taken so far are (I've described each step in detail as it might be useful for other beginners trying to get allegro set up on Ubuntu):

1) Installed subversion - sudo apt-get install subversion
2) Installed cmake - sudo apt-get install cmake
3) Made new directory in my home folder to store allegro: mkdir allegro
cd allegro
4) Got the latest version of allegro from svn - svn co https://alleg.svn.sourceforge.net/svnroot/alleg/allegro/branches/4.9
-cd allegro
5) Made a directory for the allegro build - mkdir Build
6) Installed the following libraries using synaptic - libx11-dev, libxcursor-dev, libxxf86vm-dev, libasound2-dev, libjack-dev
7) Downloaded zlib, lpng and loadpng
8) Compiled zlib - make clean
- make
9) Compiled lpng - cp scripts/makefile.linux makefile
- make test
- make install

This is where I'm up to at the moment. So I've compiled the zlib and lpng but and unable to compile loadpng, I get the following errors after I run sudo make:

gcc -W -Wall -O3 -I. -c -o loadpng.o loadpng.c
loadpng.c:9:21: error: allegro.h: No such file or directory
loadpng.c:10:38: error: allegro/internal/aintern.h: No such file or directory
In file included from loadpng.c:11:
loadpng.h:40: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.h:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.h:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.h:49: error: expected ‘)’ before ‘char’
loadpng.c: In function ‘get_gamma’:
loadpng.c:36: error: ‘AL_CONST’ undeclared (first use in this function)
loadpng.c:36: error: (Each undeclared identifier is reported only once
loadpng.c:36: error: for each function it appears in.)
loadpng.c:36: error: expected ‘;’ before ‘char’
loadpng.c:37: error: ‘gamma_str’ undeclared (first use in this function)
loadpng.c:37: warning: implicit declaration of function ‘atof’
loadpng.c: In function ‘read_data’:
loadpng.c:51: error: ‘PACKFILE’ undeclared (first use in this function)
loadpng.c:51: error: ‘f’ undeclared (first use in this function)
loadpng.c:51: error: expected expression before ‘)’ token
loadpng.c:52: warning: implicit declaration of function ‘pack_fread’
loadpng.c: At top level:
loadpng.c:63: error: expected ‘)’ before ‘*’ token
loadpng.c:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.c:221: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.c:244: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
loadpng.c:308: error: expected specifier-qualifier-list before ‘AL_CONST’
loadpng.c: In function ‘read_data_memory’:
loadpng.c:317: error: ‘MEMORY_READER_STATE’ has no member named ‘bufsize’
loadpng.c:317: error: ‘MEMORY_READER_STATE’ has no member named ‘current_pos’
loadpng.c:320: error: ‘MEMORY_READER_STATE’ has no member named ‘buffer’
loadpng.c:320: error: ‘MEMORY_READER_STATE’ has no member named ‘current_pos’
loadpng.c:321: error: ‘MEMORY_READER_STATE’ has no member named ‘current_pos’
loadpng.c: At top level:
loadpng.c:329: error: expected ‘)’ before ‘void’
loadpng.c:340: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
make: *** [loadpng.o] Error 1

To me it looks like it's looking for the allegro library but can't find it. Is there as special place I am meant to put the loadpng folder? And can someone explain to me what zlib, lpng and loadpng actually are? My understanding is zlib is a compression library installed on the operating system, i'm unsure what lpng is and loadpng is a script specifically made for allegro to make using lpng and zlib easier.

Sorry about the long post I just thought I would let everyone know exactly what I've done so far so there's no confusion.

Cheers,

Mike

Thomas Fjellstrom
Member #476
June 2000
avatar

nzmike said:

7) Downloaded zlib, lpng and loadpng

You actually need zlib, and libpng. not loadpng and lpng (whatever that is).

loadpng is an Allegro 4.2 addon, it is not compatible with Allegro 4.9.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nzmike
Member #10,841
March 2009

Thanks for the reply. By lpng I think I meant libpng. Ok so I've tried to compile allegro using make but came across some errors. Here's my output:

Scanning dependencies of target allegro
[ 0%] Building C object CMakeFiles/allegro.dir/src/allegro.c.o
[ 0%] Building C object CMakeFiles/allegro.dir/src/bitmap_new.c.o
[ 1%] Building C object CMakeFiles/allegro.dir/src/blenders.c.o
[ 1%] Building C object CMakeFiles/allegro.dir/src/config.c.o
[ 2%] Building C object CMakeFiles/allegro.dir/src/convert.c.o
[ 2%] Building C object CMakeFiles/allegro.dir/src/display_new.c.o
[ 2%] Building C object CMakeFiles/allegro.dir/src/display_settings.c.o
[ 3%] Building C object CMakeFiles/allegro.dir/src/dtor.c.o
[ 3%] Building C object CMakeFiles/allegro.dir/src/events.c.o
[ 4%] Building C object CMakeFiles/allegro.dir/src/evtsrc.c.o
[ 4%] Building C object CMakeFiles/allegro.dir/src/fshook.c.o
[ 4%] Building C object CMakeFiles/allegro.dir/src/fshook_stdio.c.o
[ 5%] Building C object CMakeFiles/allegro.dir/src/graphics.c.o
[ 5%] Building C object CMakeFiles/allegro.dir/src/inline.c.o
[ 6%] Building C object CMakeFiles/allegro.dir/src/joynu.c.o
[ 6%] Building C object CMakeFiles/allegro.dir/src/keybdnu.c.o
[ 7%] Building C object CMakeFiles/allegro.dir/src/libc.c.o
[ 7%] Building C object CMakeFiles/allegro.dir/src/math.c.o
[ 7%] Building C object CMakeFiles/allegro.dir/src/memblit.c.o
[ 8%] Building C object CMakeFiles/allegro.dir/src/memdraw.c.o
[ 8%] Building C object CMakeFiles/allegro.dir/src/memory.c.o
[ 9%] Building C object CMakeFiles/allegro.dir/src/mousenu.c.o
[ 9%] Building C object CMakeFiles/allegro.dir/src/path.c.o
[ 9%] Building C object CMakeFiles/allegro.dir/src/pixels.c.o
[ 10%] Building C object CMakeFiles/allegro.dir/src/rotate.c.o
[ 10%] Building C object CMakeFiles/allegro.dir/src/system_new.c.o
[ 11%] Building C object CMakeFiles/allegro.dir/src/threads.c.o
[ 11%] Building C object CMakeFiles/allegro.dir/src/timernu.c.o
[ 12%] Building C object CMakeFiles/allegro.dir/src/tls.c.o
[ 12%] Building C object CMakeFiles/allegro.dir/src/unicode.c.o
[ 12%] Building C object CMakeFiles/allegro.dir/src/utf8.c.o
[ 13%] Building C object CMakeFiles/allegro.dir/src/misc/bstrlib.c.o
[ 13%] Building C object CMakeFiles/allegro.dir/src/misc/vector.c.o
[ 14%] Building C object CMakeFiles/allegro.dir/src/unix/udjgpp.c.o
[ 14%] Building C object CMakeFiles/allegro.dir/src/unix/udrvlist.c.o
[ 14%] Building C object CMakeFiles/allegro.dir/src/unix/udummy.c.o
[ 15%] Building C object CMakeFiles/allegro.dir/src/unix/ufdwatch.c.o
[ 15%] Building C object CMakeFiles/allegro.dir/src/unix/ugfxdrv.c.o
[ 16%] Building C object CMakeFiles/allegro.dir/src/unix/ujoydrv.c.o
[ 16%] Building C object CMakeFiles/allegro.dir/src/unix/ukeybd.c.o
[ 17%] Building C object CMakeFiles/allegro.dir/src/unix/umain.c.o
[ 17%] Building C object CMakeFiles/allegro.dir/src/unix/umodules.c.o
[ 17%] Building C object CMakeFiles/allegro.dir/src/unix/umouse.c.o
[ 18%] Building C object CMakeFiles/allegro.dir/src/unix/usystem.c.o
/home/mike/allegro/4.9/src/unix/usystem.c: In function ‘_find_executable_file’:
/home/mike/allegro/4.9/src/unix/usystem.c:262: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result
/home/mike/allegro/4.9/src/unix/usystem.c: In function ‘_unix_get_executable_name’:
/home/mike/allegro/4.9/src/unix/usystem.c:398: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
/home/mike/allegro/4.9/src/unix/usystem.c:406: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
[ 18%] Building C object CMakeFiles/allegro.dir/src/unix/utime.c.o
[ 19%] Building C object CMakeFiles/allegro.dir/src/unix/uxthread.c.o
[ 19%] Building C object CMakeFiles/allegro.dir/src/x/xcursor.c.o
[ 19%] Building C object CMakeFiles/allegro.dir/src/x/xkeyboard.c.o
[ 20%] Building C object CMakeFiles/allegro.dir/src/x/xmousenu.c.o
[ 20%] Building C object CMakeFiles/allegro.dir/src/x/xdisplay.c.o
[ 21%] Building C object CMakeFiles/allegro.dir/src/x/xfullscreen.c.o
/home/mike/allegro/4.9/src/x/xfullscreen.c: In function ‘_al_xglx_fullscreen_set_mode’:
/home/mike/allegro/4.9/src/x/xfullscreen.c:54: warning: ‘mode.width’ may be used uninitialized in this function
/home/mike/allegro/4.9/src/x/xfullscreen.c:54: warning: ‘mode.height’ may be used uninitialized in this function
/home/mike/allegro/4.9/src/x/xfullscreen.c:54: warning: ‘mode.format’ may be used uninitialized in this function
/home/mike/allegro/4.9/src/x/xfullscreen.c:54: warning: ‘mode.refresh_rate’ may be used uninitialized in this function
/home/mike/allegro/4.9/src/x/xfullscreen.c:55: warning: ‘mode2.refresh_rate’ may be used uninitialized in this function
[ 21%] Building C object CMakeFiles/allegro.dir/src/x/xglx_config.c.o
[ 21%] Building C object CMakeFiles/allegro.dir/src/x/xsystem.c.o
[ 22%] Building C object CMakeFiles/allegro.dir/src/linux/ljoynu.c.o
[ 22%] Building C object CMakeFiles/allegro.dir/src/opengl/extensions.c.o
[ 23%] Building C object CMakeFiles/allegro.dir/src/opengl/ogl_bitmap.c.o
[ 23%] Building C object CMakeFiles/allegro.dir/src/opengl/ogl_draw.c.o
[ 24%] Building C object CMakeFiles/allegro.dir/src/opengl/ogl_display.c.o
Linking C shared library lib/liballegro-4.9.10.so
[ 24%] Built target allegro
Scanning dependencies of target a5_iio
[ 24%] Building C object addons/iio/CMakeFiles/a5_iio.dir/bmp.c.o
[ 24%] Building C object addons/iio/CMakeFiles/a5_iio.dir/iio.c.o
[ 25%] Building C object addons/iio/CMakeFiles/a5_iio.dir/pcx.c.o
[ 25%] Building C object addons/iio/CMakeFiles/a5_iio.dir/tga.c.o
[ 26%] Building C object addons/iio/CMakeFiles/a5_iio.dir/png.c.o
Linking C shared library ../../lib/liba5_iio-4.9.10.so
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/liba5_iio-4.9.10.so] Error 1
make[1]: *** [addons/iio/CMakeFiles/a5_iio.dir/all] Error 2
make: *** [all] Error 2

I don't understand the error and I've a look around the forums for a similar error but couldn't find anything. I've had a look in the usr/local/lib directory in terminal and I can see the libz.a file.

Here's what running gcc --version gives me:
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3

Anyone have any idea?

Evert
Member #794
November 2000
avatar

Could this be a 64 bit vs 32 bit issue?
EDIT: to qualify that: are you running a 64 bit system? Are you compiling Allegro for 64 bits? Is the zlib installed 32 bits or 64 bits (the "file" command should be able to tell you this)?

Elias
Member #358
May 2000

Why don't you just use Ubuntu's zlib?

--
"Either help out or stop whining" - Evert

nzmike
Member #10,841
March 2009

Yes my operating system in running in 64 but. I'm not sure how to compile allegro for 64bits. I'm also not sure if I've compiled zlib for 32bit or 64bit (I'll check this when I get home in a few hours).

I did see a zlib library in synaptic but it didn't seem to be the latest version. Does Allegro require the latest version or will the one in synaptic be fine? (I'll get the version number of the synaptic one when I get home)

Peter Wang
Member #23
April 2000

Any zlib/libpng released in the last two decades will be fine.

nzmike
Member #10,841
March 2009

Ok in Synaptic I have a package installed called 'zlib1g' which is version 1:1.2.3.4.dfsg-12ub, there is another package there called zlibc which is version 0.9k-4. I tried uninstall the zlib1g but there were quite a few programs that need this library so I decided against that. I then tried installing the zlibc package and running cmake and make again but I'm still getting the same error. I should also mention that libpng is version 1.2.27 according in Synaptic.

You suggested I run zlib with the 'file' command to check whether it was installed for a 32bit or 64 system, could you please explain how to use this command as I'm unsure what to do.

Elias
Member #358
May 2000

What you want is the -dev package, like with the other -dev packages. This one looks right to me: http://packages.ubuntu.com/jaunty/zlib1g-dev

[Edit:] Or better, just get the png dev lib, and Ubuntu will install dependencies on its own: http://packages.ubuntu.com/jaunty/libpng12-dev

--
"Either help out or stop whining" - Evert

nzmike
Member #10,841
March 2009

Ok thanks for the advice Elias. I've installed the dev packages you suggested and they are located in a folder called lib64 in usr. The make file is looking for zlib.a in /usr/lib. How do I change this to point to usr/lib64. I had a look around the config files but couldn't find anything to do with zlib.

I'm getting close I can feel it :-). Thanks for the help so far.

Thomas Fjellstrom
Member #476
June 2000
avatar

Is it allegro's makefile thats looking for /usr/lib? If so, you can pass /usr/lib64 to configure with its --libdir argument.

edit: Oh crap, I forgot you're using Allegro 4.9, there is no configure... Gimme a moment, I'm sure theres a way to pass the same info to cmake.

edit2: Yup, just set LIB_SUFFIX to 64 when running cmake (or set it in ccmake). Using cmake, that'd be:

cmake -DLIB_SUFFIX=64 ..

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nzmike
Member #10,841
March 2009

I tried adding the flags you suggested but I'm still getting the same error:

mike@mike:~/allegro/4.9/Build$ sudo cmake -DLIB_SUFFIX=64 ..
-- Allowing GCC to use SSE instructions
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
WARNING: libjpeg not found, disabling support
-- Could NOT find FLAC (missing: FLAC_INCLUDE_DIR FLAC_LIBRARY)
WARNING: libFLAC not found, disabling support.
-- Could NOT find VORBIS (missing: VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBIS_LIBRARY)
WARNING: libvorbis not found, disabling support.
-- Could NOT find SNDFILE (missing: SNDFILE_INCLUDE_DIR SNDFILE_LIBRARY)
WARNING: libsndfile not found, disabling support.
-- Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
WARNING: FreeType not found, disabling support.
-- checking for module 'gtk+-2.0'
-- package 'gtk+-2.0' not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mike/allegro/4.9/Build
mike@mike:~/allegro/4.9/Build$ sudo make
[ 24%] Built target allegro
Linking C shared library ../../lib/liba5_iio-4.9.10.so
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/liba5_iio-4.9.10.so] Error 1
make[1]: *** [addons/iio/CMakeFiles/a5_iio.dir/all] Error 2
make: *** [all] Error 2

It still seems to be looking at /usr/local/lib/libz.a for the libz.a where as the one I've installed is at /usr/lib64/libz.a as far as I believe. There is a libz.a at both these locations as well as at /usr/lib/libz.a.

Thomas Fjellstrom
Member #476
June 2000
avatar

Ok, blow away your Build dir first and try again. For some reason its pulling in libz from /usr/local, did you install that yourself? You should probably remove it if you did (chdir into the build dir for that install and make uninstall it).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nzmike
Member #10,841
March 2009

Thanks, deleting the Build directory seemed to do the trick. I've compiled it and now I'm tried to get it to work with Code::Blocks. I've added 'allegro5-config --libs' (without the quotation marks)
to the other linker settings but when I compile it says it cannot find allegro.h.

Thomas Fjellstrom
Member #476
June 2000
avatar

Did you remember to install allegro?

sudo make install

Also, you'll want to add `allegro5-config --libs` with the backticks to the "Extra linker options" pane in Code::Blocks.

I can't recall actually if the pkgconfig stuff got into 4.9.9[.1] or not, but if its there, go into the project settings and you'll see a large list of packages that pkgconfig exports, allegro and its addons (that got installed) should be in there, so you won't have to mess with allegro5-config at all.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nzmike
Member #10,841
March 2009

Cheers Thomas I just needed to add the back-ticks. Ok so I've compiled a basic Allegro5 program but when the application is run it comes up with "/home/mike/project/bin/Debug/COSC345: error while loading shared libraries: liballegro-4.9.10.so: cannot open shared object file: No such file or directory

Press ENTER to contine."

So it looks like its trying to find liballegro-4.9.10.so in my project folder. Why is it trying to do this?

Thomas Fjellstrom
Member #476
June 2000
avatar

nzmike said:

So it looks like its trying to find liballegro-4.9.10.so in my project folder. Why is it trying to do this?

I'm assuming it really isn't. But that you let cmake set the install dir to /usr/local, and /usr/local/lib isn't always in the ld.so path (check /etc/ld.so.conf.d/libc.conf or one of the other files in the same dir for /usr/local/lib if it isn't there, add it to libc.conf, and run sudo ldconfig).

Edit: Or of course, uninstall allegro, and tell cmake to install to /usr instead: cmake -DLIB_SUFFIX=64 -DCMAKE_INSTALL_PREFIX=/usr .. and redo the install.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

nzmike
Member #10,841
March 2009

It works!! Thank you so much for everyone's time, you've all been extremely helpful. Hopefully this thread proves useful for someone else having problems compiling the latest version of Allegro.

Go to: