Tutorials
The Sourceforge user Nyrel had problems when he wanted to use Andorra 2D on his Linux system. He has written a guide to help all other Andorra 2D users, who attempt to do the same:
Getting Andorra 2D 0.4.5.1 to work on linux i386 and amd64
I have checked these instructions on my ThinkPad laptop (i386, kubuntu 8.10, fpc 2.2.2, lazarus 0.9.26) and on my stationary computer (amd64, kubuntu 8.04 64bit, fpc 2.2.2, lazarus 0.9.27 svn version from about 2009-01-01).
Prerequisites:
Working installation of FPC and Lazarus.
I have decided to do this howto step by step and show all intermediate error messages that you get until you have setup everything correctly. This might help others to find this thread when searching for their error messages.
Note that the exact error messages that you will get might be slightly different due to differences in system setup. Feel free to add any more error messages and (hopefully) solutions to this thread.
Install Andorra 2D
Download Andorra 2D and unpack it to the directory where you like to install it. I will use:
~/program/andorra
Build a test project - Part 1
Open the SimpleNonVCL project in lazarus. You will find it here:
~/program/andorra/demos/Simple/SimpleNonVCL/NoVCL.lpi
Hit F9 to try to compile and run it, you will not get very far though as there are some things you need to change:
Error 1:
Main.pas(50,31) Error: Identifier not found "ReportMemoryLeaksOnShutdown"
Solution 1:
Just uncomment
Error 2:
/usr/bin/ld: cannot find -lfreeimage
Solution 2:
The FreeImage library need to be installed. Start the package manager for your linux distribution (adept, synaptic, rpmdrake etc) and search for freeimage and install it. On my system the package was called libfreeimage3.
Error 3 (again):
/usr/bin/ld: cannot find -lfreeimage
Solution 3:
The FreeImage library is not found since the library file is called /usr/lib/libfreeimageplus.so.3 instead of /usr/lib/libfreeimageplus.so. Make a symbolic link to correct this:
sudo ln -s /usr/lib/libfreeimage.so.3 /usr/lib/libfreeimage.so
More information about the FreeImage issue can be read in the "Using FreeImage with Linux and Lazarus" tutorial. You don't have to use FreeImage with Andorra 2D. The FreeImage library is just used in this demo to load png images. You might also try the units "AdPNG" or "AdDevIL" instead of "AdFreeImage".
Error 4:
/usr/bin/ld: cannot find -lGL
Solution 4:
Wrong name of the library file again. Create a symbolic link:
sudo ln -s /usr/lib/libGL.so.1 /usr/lib/libGL.so
At this point the project compiles successfully on my system. But fails when it runs.
Error 5:
Exception while creating process: Executable not found: "xterm"
Solution 5:
Install xterm using your package manager. Usually it is allready installed, but this was on an almost clean kubuntu 8.10 installation.
Error 6:
Exception: No compatible Andorra 2D plugin library found.
The exception occurs on the following statement:
Main.pas, 65: AdDraw.DllName := DefaultPlugin
This error is perfectly allright at this point as we have not yet compiled any plugin to use. Let's move on to the next part!
Build the Andorra plugin library - Part 1
Open the andorraOGL project:
~/program/andorra/src/dll/opengl/andorraOGL.lpi
Go to Project->Project options and change the name of the generated binary from:
../../../bin/AndorraOGLLaz.dll
to:
../../../bin/libAndorraOGLLaz.so
Try to build the project with Ctrl-F9.
At this point the project should compile sucessfully if you are running on i386 and you may continue to "Build a test project - Part 2".
If you are running a 64 bit system there is a few more issues to work
out.
Error 7:
/usr/bin/ld: ~/program/andorra/src/dcu/AdClasses.o: relocation R_X86_64_32S against _$ADCLASSES$_Ld1' can not be used when making a share object; recompile with -fPIC
Solution 7:
Well, I'm not exactly sure what this is about, but let's follow the advice and recompile with "-fPIC". Go to Project->Compiler options->Other and write -fPic in the box for custom options.
At this point the project should compile correctly, but there is still some issues to fix before it will actually work. We get to that soon!
Build a test project - Part 2
When you built the AdorraOGL project above it generated the plugin library file in the andorra bin directory (~/program/andorra/bin). We need this file to get the test project running, so copy the library file to your project directory:
cp ~/program/andorra/bin/libAndorraOGLLaz.so ~/program/andorra/demos/Simple/SimpleNonVCL/
Open the SimpleNonVCL project in lazarus again and press F9 to try to run it.
If you are running i386 everything should work fine this time, and you should see a black window with an Andorra logo, and a text that follows the mouse cursor.
If you still get an exception on the assignment of DllName, you can try to change that line from:
to:
However if you are running amd64 you will get an exception on the OpenGL initialization.
Error 8:
Main.pas: AdDraw.Initialize ->
AdDraws.pas, 1453: AdAppl.Initialize(FWnd) ->
OGLMain.pas, 249: InitOpenGL ->
dglOpenGL, 8848: glXGetProcAddress := glProcedure('glXGetProcAddress');
dglOpenGL, 8809: Result := GetProcAddress(LibHandle, ProcName);
dglOpenGL, 8702: Result := dlsym(Pointer(LibHandle), ProcName);
The error occurs in the function LoadLibrary, where the return value of dlopen is casted to a THandle. The problem is that THandle is defined as 32-bit, but the return value is 64-bit.
begin
Result := THandle(dlopen(Name, RTLD_LAZY));
end;
So we need to fix this in the plugin library.
Build the Andorra plugin library - Part 2
Open the andorraOGL project again.
Solution 8:
The solution is to add a new type definition of THandle in all places where it occurs:
~/program/andorra/src/dll/opengl/OGLShader.pas:
118: function TOGLShaderSystem.LoadShaderPlugin(AID: TAdVeryShortString): boolean;
119: type // Added
120: THandle = Int64; // Added
~/program/andorra/lib/dglOpenGL.pas:
225: type
226: THandle = Int64; // Added
These problems should be fixed with new versions of Andorra 2D (greater 0.4.5.1).
Now you should be able to compile the project successfully and generate a valid 64-bit plugin library. With the new version of libAndorraOGLLaz.so you should be able to compile and run the test project successfully!
I have been working through the tutorials on the Andorra website and so far I have completed the sprite engine tutorial without any (major) problems.
Note: THandle is used in some other files too (just search for it). It is probably a wise idea to add the redefinition to them too, but the above changes is enough to get things started.
This page was generated with the help of the following PHP-Scripts: GeSHi a free PHP Syntax highlighter and StringParser_BBCode a free BBCode Parser.