BlitzMax on Ubuntu AMD 64: A Solution

Archives Forums/Linux Discussion/BlitzMax on Ubuntu AMD 64: A Solution

dawlane(Posted 2008) [#1]
I have finally figured out a way to use BlitzMax in the 64 bit version Ubuntu so that every thing works (so far). The only down side is that you may have to sacrifice 1.5GB (oops got it wrong read on) of hard drive space to do it (I could be wrong as the chroot's home folder is linked to /home).

EDIT: You only have to sacrifice a few hundred megs (if that), thats the chroot directories and the 32bit software thats needed to compile for 32bit apps (synaptic,gcc,g++, 32bit libs and a few others). I originally thought it installed almost a full distro ( checked the size of chroot folder and was 1.5GB ). As it turns out the /chroot/home folder is system linked to /home and I had a bit of stuff there.

The solution is simple in theory but a little tricky to set up as we have to create a “second minimal” install of Ubuntu as a chroot ( here's the description http://en.wikipedia.org/wiki/Chroot ).

What I list here can be found here http://ubuntuforums.org/showthread.php?t=24575 by Crad

NOTE DISCLAIMER: I WILL NOT BE HELD RESPONSIBLE IF.....
1) YOU SCREW UP YOUR SYSTEM.
2) THE WORLD COMES TO AN END.
3) YOU CAN'T GET IT TO WORK, BECAUSE I DID GET IT TO WORK.


Step 1:
Open a command terminal. Note replace hardy with the code name of the Ubuntu distribution (keep this terminal open it saves time).

sudo apt-get install dchroot debootstrap
sudo mkdir /chroot/
sudo gedit /etc/dchroot.conf
Add this line to dchroot.conf:
hardy /chroot

sudo debootstrap --arch i386 hardy /chroot/ http://archive.ubuntu.com/ubuntu
sudo chroot /chroot/
dpkg-reconfigure locales

Step 2:
In another terminal window (or by existing chroot):

sudo gedit /chroot/etc/apt/sources.list
Add the following 2 lines to sources.list:
deb http://archive.ubuntu.com/ubuntu hardy main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe multiverse

(We do this step because gedit has yet to be installed in the chroot environment)

Step 3:
In your chrooted environment (chroot /chroot):

apt-get update
apt-get upgrade

Step 4:
In another terminal window (or by existing chroot):

sudo cp /etc/passwd /chroot/etc/
sudo cp /etc/shadow /chroot/etc/
sudo cp /etc/group /chroot/etc/
sudo cp /etc/sudoers /chroot/etc/
sudo cp /etc/hosts /chroot/etc/
sudo gedit /etc/fstab
Add the following 6 lines to fstab:
/home /chroot/home none bind 0 0
/tmp /chroot/tmp none bind 0 0
/dev /chroot/dev none bind 0 0
/proc /chroot/proc proc defaults 0 0
/media/cdrom0 /chroot/media/cdrom0 none bind 0 0 ( this can be omitted as it can cause problems mounting and unmounting cd/dvd media)
/usr/share/fonts /chroot/usr/share/fonts none bind 0 0
(you may get a complaint about this not mounting so you will have to do mkdir /chroot/usr/share/fonts before running sudo mount -a)

sudo mkdir /chroot/media/cdrom0
sudo mount -a
sudo gedit /usr/local/bin/do_dchroot
Add the 2 following to do_dchroot:
#!/bin/sh
/usr/bin/dchroot -d "`echo $0 | sed 's|^.*/||'` $*"
sudo chmod 755 /usr/local/bin/do_dchroot

Step 5:
In a new terminal:

dchroot -d
sudo apt-get install synaptic
sudo ln -s /usr/sbin/synaptic /usr/sbin/synaptic32
exit
sudo ln -s /usr/local/bin/do_dchroot /usr/local/bin/synaptic32
sudo synaptic32



Now we need to install the libs and the GCC compiler.
In synaptic32 (type it in a command terminal) find and mark these for installation or try apt-get install in the chroot environment.

UPDATE: If you want to use Ubuntu 8.10 (intrepid) then you will have to manual install g++-3.3/gcc-3.3 from the hardy section in the ubuntu archives. For more on this follow this thread.
http://www.blitzbasic.com/Community/posts.php?topic=81247

g++-3.3
gcc-3.3 ..... (NOTE the gcc-doc package will throw errors so just remove it)
libglu1-mesa-dev
x11proto-core-dev
x11proto-gl-dev
x11proto-kb-dev
libxxf86vm-dev
libasound2-dev
libidn11-dev


And if you want to use gtk applications using Brucey's GTK mod

libglib2.0-dev
libgtk2.0-dev



Now we have to make a couple of system links so the 32bit version of GCC can be found

sudo ln -s /usr/local/bin/do_dchroot /usr/local/bin/g++-3.3
sudo ln -s /usr/local/bin/do_dchroot /usr/local/bin/gcc-3.3


As alway make sure you have 3D Accelarted drivers installed and desktop effects turned off (only for some graphics cards).
And don't forget when you update the 64bit version update the minimal install too.

With any luck BRL may build BlitzMax against the GCC 4.2 suit so all we have to do then is install the mulit-libs package as the chroot method is over kill. (It's how they got 32bit applications to build and work in the early days of 64bit linux)


Torrente(Posted 2008) [#2]
Works perfectly, and awesomely.

And I didn't even have to turn off desktop effects.

Thanks!


WildStorm(Posted 2008) [#3]
print "test"

leads to:


Building untitled1
Compiling:untitled1.bmx
flat assembler version 1.64
3 passes, 2508 bytes.
Linking:untitled1.debug
keyctl_search: Required key not available
Perhaps try the interactive 'ecryptfs-mount-private'
W: Konnte nicht in das Verzeichnis »/media/sda4/Receiving/Web/BlitzMax« wechseln: No such file or directory
W: Verwende stattdessen Verzeichnis »/«
I: [Chroot hardy] Starte Kommando: »g++-3.3 -m32 -s -Os --eh-frame-hdr -pthread -static-libgcc -o /media/sda4/Receiving/Web/BlitzMax/tmp/untitled1.debug /media/sda4/Receiving/Web/BlitzMax/tmp/ld.tmp -L/usr/X11R6/lib -L/usr/lib -L/media/sda4/Receiving/Web/BlitzMax/lib«
g++-3.3: /media/sda4/Receiving/Web/BlitzMax/tmp/ld.tmp: No such file or directory
g++-3.3: no input files
keyctl_search: Required key not available
Perhaps try the interactive 'ecryptfs-mount-private'
Build Error: Failed to link /media/sda4/Receiving/Web/BlitzMax/tmp/untitled1.debug
Process complete


any idea?


---------------------------


and ehm, how can i uninstall this chroot thing again?


dawlane(Posted 2008) [#4]
Try adding in fstab
/media/ /chroot/media/ none bind 0 0

and then sudo mount -a

This basically will link the /media to the chrooted /media. Note /chroot/media must exist for this to work. Only ever tried this with the /media/cdrom0 and caused headaches accessing the DVD/CD device.

The other is to move your BlitzMax folder to your users home directory.

There is another way to get BlitzMax working on a 64bit machine and thats by using gcc-4.x read here for more http://www.blitzbasic.com/Community/posts.php?topic=81261
I haven't check the SVN for a bit so there may be a fix there already, but one problem you will face is build MaxGTK applications.

To remove the chroot environment as root delete the chroot directory, remove or comment out the new lines in fstab and remove the system links and /usr/local/bin/do_dchroot.


DH(Posted 2009) [#5]
It's worth adding that this works for jaunty as well!


D4NM4N(Posted 2009) [#6]
I had a problem with -so-5 of libstdc++ (as in it is not there)
Here is how i got a fix:

Code:
Add these:

deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid main restricted
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid multiverse
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-security main restricted
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-security multiverse
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-security universe
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid universe
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-updates main restricted
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-updates multiverse
deb http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ intrepid-updates universe

to "sudo gedit /etc/apt/sources.list.d/intel_suite.list" then do "sudo apt-get update", "sudo apt-get install libstdc++5",you only need one of these lines, but I couldnt be bothered to filter (nor could the guy who gave me the rep names :).

I am not sure why the only thing of mine that ever seems to break over this is blitzmax. All my binaries written in c++ & irrlicht work fine.
Any idea why?


Brucey(Posted 2009) [#7]
What did you need "5" for?


D4NM4N(Posted 2009) [#8]
Compiled apps are asking for it.