[solved]Compiling an Irrlicht program for "distribution"

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Nyx Erebos
Posts: 33
Joined: Fri Mar 01, 2013 1:26 am

[solved]Compiling an Irrlicht program for "distribution"

Post by Nyx Erebos »

Hello there,

usually I can find quite easily solutions to any Irrlicht related problem so for my first post it'll not be an (fully) Irrlicht related question.

I've made an Irrlicht program (navmeshes with A*) using opengl as renderer and pthreads, and now that I've finally got it to work I want to try to give it to a friend. So my question is basically how do I do that ? I want to compile my program and give it to him without him having to install anything. I've tried numerous things to get it to work but with no success (I've been messing around with libIrrlicht.a libIrrlicht.so and so on for two days). If there's a tutorial out there on how to do it on linux (ubuntu) that would be great or if you could give me the steps to follow I'd give you an internet hug :wink: (a tuto on how to do it on windows would be awesome too).

Thanks for your help and pardon my english, I'm french :) .
Last edited by Nyx Erebos on Fri Mar 01, 2013 5:44 pm, edited 1 time in total.
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: Compiling an Irrlicht program for "distribution" (how to

Post by polylux »

If your dependencies are not too complex you could instruct your friend to just install the needed libraries via his package manager, like

Code: Select all

sudo apt-get install irrlicht <additional deps here>
Other than that, try to link everything as statically as possible (-> use the .a instead of the .so), copy any left runtime deps into the folder with the binary and include that folder in the lib path. Use your favorite search engine for further info or feel free to ask here. :)

Cheers!
beer->setMotivationCallback(this);
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Compiling an Irrlicht program for "distribution" (how to

Post by serengeor »

There's also a page on wiki for this: http://irrlicht3d.org/wiki/index.php?n= ... ingOnLinux :wink:
Working on game: Marrbles (Currently stopped).
Nyx Erebos
Posts: 33
Joined: Fri Mar 01, 2013 1:26 am

Re: Compiling an Irrlicht program for "distribution" (how to

Post by Nyx Erebos »

Thanks for the quick answers :) .
serengeor wrote:There's also a page on wiki for this: http://irrlicht3d.org/wiki/index.php?n= ... ingOnLinux :wink:
I've already tried that and several variations.
polylux wrote:If your dependencies are not too complex you could instruct your friend to just install the needed libraries via his package manager, like

Code: Select all

sudo apt-get install irrlicht <additional deps here>
Actually I want to avoid that.
polylux wrote:Other than that, try to link everything as statically as possible (-> use the .a instead of the .so), copy any left runtime deps into the folder with the binary and include that folder in the lib path.
I'm trying hard but can't get it to work :( . Here's my makefile (don't mind the windows parts) :

Code: Select all

# Irrlicht Engine Demo Makefile
Target = Demo
Sources = Foe.cpp Interaction.cpp LightNode.cpp MyEventReceiver.cpp Node.cpp ObjectNode.cpp ParticleNode.cpp PathFinding.cpp TerrainNode.cpp Timer.cpp WaterNode.cpp main.cpp
 
CPPFLAGS = -I./include/Irrlicht -I./include/pthread -I/usr/X11R6/include
CXXFLAGS = -Wall -O3 -ffast-math -std=c++0x -g
 
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
 
all: all_linux
 
# target specific settings
all_linux: SYSTEM=Linux
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L./linux -lIrrlicht -L./linux -lpthread -lGL -lGLU -lXext -lX11 -DLINUX
 
all_win32 clean_win32: SYSTEM=Win32-gcc
all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm
 
all_win32 clean_win32: SUF=.exe
# name of the binary - only valid for targets which set SYSTEM
DESTPATH = ./$(Target)$(SUF)
 
OBJ = $(Sources:.cpp=.o)
 
all_linux all_win32: $(OBJ)
    $(warning Building...)
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $(DESTPATH) $(LDFLAGS)
 
clean: clean_linux clean_win32
    $(warning Cleaning...)
    @$(RM) $(OBJ)
 
clean_linux clean_win32:
    @$(RM) $(DESTPATH)
 
.PHONY: all all_win32 clean clean_linux clean_win32
I don't know if all the libs dependancies are necessary but even when I remove them I've got the same errors. I have the libIrrlicht.a and pthread.a in ./Linux and the headers in ./include/Irrlicht and ./include/pthread. What do you mean by runtime deps ?

After compiling my program it works on the computer where I developped it but when I try to launch it from Virtualbox on another computer (yeah I know it's maybe not the best way to test it but I don't want to install another linux just to be sure that the program doesn't get the lib from usr/lib) I get this :

Code: Select all

$./Demo
./Demo: error while loading shared library: libIrrlicht.so.1.7a: cannot open shared object file: No such file or directory
When I type ldd Demo :

Code: Select all

    linux-gate.so.1 =>  (0xb77b7000)
    libIrrlicht.so.1.7a => not found
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7788000)
    libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb769e000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb765b000)
    libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb763e000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb748b000)
    /lib/ld-linux.so.2 (0xb77b8000)
It doesn't find libIrrlicht.so.1.7a and the pthread lib is linked from lib/i386-linux-gnu/. I think there's something I don't understand about compiling (and I promise I searched, a lot :lol: ).
Nyx Erebos
Posts: 33
Joined: Fri Mar 01, 2013 1:26 am

Re: Compiling an Irrlicht program for "distribution" (how to

Post by Nyx Erebos »

I feel a bit stupid now, I thought it was an Irrlicht setup related problem but no it was really just a compiling knowledge fail. I just had to find out that it was not a good idea to try to link staticly opengl and pthread, ant to use the options -static and -dynamic. Thanks for your help anyway :)
Post Reply