This has been asked a couple of times. Until now i wasn’t much help there because i never tried this myself. So now i tried it and had some success. I was able to compile the PureBasic IDE, which means that pretty much all non-multimedia libs must be working. If you don’t want to wait for PureBasic 64bit for Linux (planned for 4.40) then here is a step by step guide.
There is a guide for Ubuntu 8.10 and OpenSUSE 11.1 64bit (always starting from a clean installation). If you have a slightly different version of one of these distributions then it may work for you as well with some luck. If you have a different distribution, then read this anyway. There are some tips on the bottom on how you could make this work for your distribution as well.
PureBasic on Ubuntu 8.10 64bit
First download and unpack the PureBasic package. Then open a console and set up the environment variables for the compiler and try running it “pbcompiler -h”. If you started from a clean install, then not even this will work (you will get a weird error like “No such file or directory”). So we first need the runtime environment for 32bit programs:
sudo apt-get install ia32-libs
Note that this installs a lot of stuff (120Mb). After this is completed, the compiler should at least be able to run. At this point you should also be able to run the IDE. But even trying to compile an empty program will cause linker errors. So what we need next is the basic gcc and libc6 support for compiling 32bit programs:
sudo apt-get install gcc-multilib libc6-i386 libc6-dev-i386
After that, you should be able to compile your first (console only) programs, and also use the PureBasic debugger.
The next big thing are Gtk and SDL. Unfortunately there are no special 32bit development versions of these packages available (something like “libgtk2.0-dev-i386”), so we have to use some tricks. To compile with PB, we actually only need two things: The library files and the properly working pkg-config sdl-config tools to actually find them (and tell the linker which libraries to link).
Lets start with the configuration tools: here we can actually use the ones that come with the regular 64bit packages, so just install those:
sudo apt-get install libgtk2.0-dev libsdl1.2-dev
If you try to compile a program with a MessageRequester() before and after this step, you will notice that the linker errors are reduced from a huge pile of unresolved symbols to just not finding a compatible library. So all we need now is some compatible library files. It turns out that all the needed libraries are already installed with the “ia32-libs” package, because you can use a dynamic library (.so) for linking as well (the linker will automatically generate a static lib from that). The only thing that is missing really are some symbolic links to help the linker find those dynamic ones, thats all.
I found a nice script here that creates these links and extended it by a few more links needed for PureBasic. Put the following into a textfile and execute it as root (“sudo sh myfile.sh”):
#!/bin/sh cd /usr/lib32 for lib in gio-2.0 gdk-x11-2.0 atk-1.0 gdk_pixbuf-2.0 \ pangocairo-1.0 pango-1.0 pangoft2-1.0 \ gobject-2.0 gmodule-2.0 glib-2.0 gtk-x11-2.0; do ln -s -f lib$lib.so.0 lib$lib.so done ln -s -f libcairo.so.2 libcairo.so ln -s -f libfreetype.so.6 libfreetype.so ln -s -f libz.so.1 libz.so ln -s -f libfontconfig.so.1 libfontconfig.so ln -s -f /usr/lib32/libX11.so.6 /usr/lib32/libX11.so ln -s -f /usr/lib32/libXrender.so.1 /usr/lib32/libXrender.so ln -s -f /usr/lib32/libXext.so.6 /usr/lib32/libXext.so ln -s -f libgthread-2.0.so.0 libgthread-2.0.so ln -s -f libSDL-1.2.so.0 libSDL.so ln -s -f libstdc++.so.5 libstdc++.so
Thats it! Now most libraries should work fine. The IDE compiled fine with this setup. As far as i understand the page above, this step will actually not be needed for the next stable Ubuntu release.
Some PureBasic libs that have special dependencies will still not work however. The commands from the following libraries will compile/link fine, but not work with this setup:
- Sound, SoundPlugin, Module – I am not sure why these do not work. Could be because i am running VMWare and have no tools installed yet. Somebody else will have to try this.
- All 3D Engine related libraries – I did not look deeper into why the engine does not load. Maybe another time. It actually starts loading, but you never see a screen.
- the WebGadget() – This does not even work out of the box on some 32bit systems. I did not bother looking deeper into that.
The following Libraries will not even link. The reason is simply that the “ia32-libs” package does not include 32bit versions of them. To get them to work you would have to compile them manually in 32bit mode. Maybe i will try that another time.
- PrinterOutput() – needs libgnomeprint2.2
- Movie lib – needs libxine
- Database lib with ODBC – needs libiodbc2 (Note: SQLite works fine as it is included in PB)
PureBasic on OpenSUSE 11.1 64bit
I started from a clean installation with Gnome desktop and no other packages added in the setup.
Open the “Software Management” in Yast and install the following packages:
- gcc-32bit
- gtk2-devel
- sdl-devel-32bit
- libgnomeprint-devel
- libgnomeprint-32bit
- libgnomeprintui-devel
- libgnomeprintui-32bit
- libxine-devel
- libxine1-32bit
Then copy the code below to a text file and run it in a shell as root (“sudo sh myfile.sh”):
#!/bin/bash cd /usr/lib for lib in gio-2.0 gdk-x11-2.0 atk-1.0 gdk_pixbuf-2.0 \ pangocairo-1.0 pango-1.0 pangoft2-1.0 \ gobject-2.0 gmodule-2.0 glib-2.0 gtk-x11-2.0; do ln -s -f lib$lib.so.0 lib$lib.so done ln -s -f libcairo.so.2 libcairo.so ln -s -f libfreetype.so.6 libfreetype.so ln -s -f libfontconfig.so.1 libfontconfig.so ln -s -f libstdc++.so.6 libstdc++.so ln -s -f /lib/libz.so.1 /lib/libz.so ln -s -f /lib/libgcc_s.so.1 /lib/libgcc_s.so ln -s -f libgthread-2.0.so.0 libgthread-2.0.so ln -s -f libgnomeprint-2-2.so.0 libgnomeprint-2-2.so ln -s -f libart_lgpl_2.so.2 libart_lgpl_2.so ln -s -f libxml2.so.2 libxml2.so ln -s -f libgnomeprintui-2-2.so.0 libgnomeprintui-2-2.so ln -s -f libgnomecanvas-2.so.0 libgnomecanvas-2.so ln -s -f libxine.so.1 libxine.so ln -s -f libpng12.so.0 libpng.so
This should do the trick to allow PB to compile. Note that unlike on Ubuntu, the Movie lib and PrinterOutput() will work just fine here. The other mentioned library problems are the same as on Ubuntu though.
PureBasic on other 64bit Linux distributions
Ok, i cannot do this for all distributions, but the steps on your Linux of choice should be fairly similar, just with slightly different package/filenames:
- Install the 32bit runtime environment (sometimes this is preinstalled). You know you succeeded when the IDE and compiler can be started.
- Install what is needed to build basic 32bit programs. This is usually a special gcc package and a special libc6-dev package. You know you succeeded if you can compile an empty sourcecode without errors.
- Install the required libraries. If they exist as a 32bit-devel package then that is perfect. If they only exist as a 32bit runtime version (maybe included in a larger 32bit package) then install that plus the 64bit devel package. Then add any missing symbolic links in your 32bit lib directory. Usually the linker looks for a file like “libSDL.so” and the folder will contain a “libSDL1.2.so.0” or similar. (usually just with the extra .0) Just add a link as the scripts above do. If there is not even a 32bit runtime package for a library then you can only try compiling them manually. Use a small testcode like a MessageRequester() and try the above until the linker no longer complains about any libraries.
The required packages (all as devel version, Gtk and SDL are the most important):
- libgtk2.0
- libsdl1.2
- libstdc++ (for ScintillaGadget)
- libgnomeprint2.2 and libgnomeprintui (for PrinterOutput())
- libxine (for Movie lib)
- libiodbc (for ODBC database)
Thats pretty much it. I hope you can get this working on your system. If there are more problems just ask. I would not call myself a Linux expert but i will try to help if possible. If you get PureBasic working on another distribution, please publish your exact steps somewhere so others can benefit too.