How to: BlitzMax on 32/64bit Linux Mint 15/Ubuntu

Archives Forums/Linux Discussion/How to: BlitzMax on 32/64bit Linux Mint 15/Ubuntu

dawlane(Posted 2013) [#1]
Greetings to all.

EDIT: 27/06/2013: At the bottom of this first post I have added a patch script for BlitzMax 1.48.
EDIT: 12/06/2013: I've update this how to so the dependencies are loaded by a script as some people have problems following it. There's also a Work In Progress install script in a post further down that at some point will do the most common package managers.

Why the topic title "BlitzMax on 32/64bit Linux Mint 15/Ubuntu" you may ask. Well as there are two versions of Linux Mint one that's based of the Ubuntu branch
and the other follows the Debian testing branch. So what is written here should in theory work for Ubuntu as well.
NOTE: Linux Mint Debian Edition (LMDE) hasn't been tested if it doesn't work you may want to read BlitzMax on Debian 7 "Wheeze" 32/64.
It's written for Debian 7 (Wheeze) 64bit ands some of the system links may need up dating.

I finally got round to installing Linux Mint 15 onto my machines. One was a clean install the other was a system upgrade.
It's been a while since I did an upgrade without doing it as a clean install and it went rather well. The only problem I had
was that I had to reaffirm the desktop manager at the log screen otherwise just logging on caused a crash.
I would still recommending upgrading by doing a clean install.

OK what's different this time to get our beloved BlizMax working again. Very little in fact we just need to add a bit of code
either into BlitzMax/mod/brl.mod/appstub.mod/appstub.bmx or on one of your source files. More on that later.

NOTE: If you find that you have problems with blitzmax applications running with the free drivers that come with the distribution then try and use one of the proprietary drivers.

Quick Installer for just the dependencies.


To use this script make a text file on your desktop named bmax-install.sh and copy and past the above into this text file. Save it, rigth click it and set the files 'allow execution' permission checkbox in it's permissions properties menu.
Then open a terminal, then type
sudo $HOME/Desktop/bmax-install.sh

enter your root/sudo pass word when it asks for it and answer 'y' to everything.

After it's finished; open MaxIDE have a go at compiling something. You may get something like this error.
/usr/bin/ld: /home/jason/Desktop/BlitzMax/mod/pub.mod/lua.mod/lua.release.linux.x86.a(loadlib.c.release.linux.x86.o): undefined reference to symbol 'dlopen@@...'
/usr/bin/ld: note: 'dlopen@@...' is defined in DSO /lib/i386-linux-gnu/libdl.so.2 so try adding it to the linker command line
/lib/i386-linux-gnu/libdl.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Build Error: Failed to link /home/jason/Desktop/BlitzMax/test/test

What does this mean. Well it means that Blitzmax is having a hard time passing on the required flag to the linker.

To solve this we need to add
Import "-ldl"
to either your bmx project start file or some where that will always be seen by the blitz compiler like 'BlitzMax/mod/brl.mod/appstub.mod/appstub.bmx' should be good.
Don't forget to rebuild the modules if you place it there!

The sound issue.
Yes this is still here as it's a BlitzMax issue so you'll need to modify some files still. Unless your going to use OpenAL.
I used skidracer's pulse audio driver as an alternative.
Here's the link read it through and what ever you do don't use MaxIDE to copy and paste the cpp files; use a text editor like notepad. skid's also also fixed the ALSA driver as well. See here for details.
These files need to go into path_to_blitzmax/BlitzMax/mod/pub.mod/freeaudio.mod
One thing to note is that BlitzMax/mod/brl.mod/freeaudioaudio.bmx is related to this so you may want to update the code at the bottom to reflect what sound driver name your using.
Then rebuild all the modules.


EDIT: 27/06/2013
As mentioned above I have added a patch script for Blitz Max 1.48.
To use it make a new empty file in the same directory where you have extracted a fresh copy of BlitzMax and name it "patch.sh" and set the permissions to execute just like the install script above. Then copy and paste the code below, save it and then open a terminal; cd to the directory and then type ./patch.sh.

Remember that you will need to rebuild the modules. To do this it's best not to use the MaxIDE as it can crash if something goes wrong leaving you thinking that the patch has failed.
Instead while in the terminal cd to BlitzMax/bin directory and type: bmk makemods -a




Wiebo(Posted 2013) [#2]
Thanks for this guide. I've installed Max on Mint 14 and I've written this guide some time ago, which might be of interest to people as well:

https://docs.google.com/document/d/1oP308DiqTnCRjQm9PCL5lXoN9vZwY3YKxb1kro58ua8/edit?usp=drive_web


32 bit only though.


dawlane(Posted 2013) [#3]
Been meaning for a while to write a proper install script for Mint/Ubuntu that automated installation along with fixing stuff on the fly. So all you needed to do was just place the BlitzMax zip file in the same directory as the installer and let it run. Just don't seem to have the will power to do it as there's just too many distractions in my life at the moment.


Captain Wicker (crazy hillbilly)(Posted 2013) [#4]
thank you so much. I can compile again! :D


JoshK(Posted 2013) [#5]
None of this works. Is there a version of Linux that actually works?


dawlane(Posted 2013) [#6]
Need to see the output from BlitzMax console. With out seeing that no one will be able to help. It could be something as simple as needing hardware acceleration enabled or just the bad luck that the hardware isn't supported. A thing with an intel graphics card or old graphics hardware is know to be a problematic.


Wiebo(Posted 2013) [#7]
JoshK: It does work, you must be doing something wrong somewhere, sorry.


dawlane(Posted 2013) [#8]
@Wiebo: I bet you any money he was in to much of a rush to read the whole post and tried to use the stuff for the 64 bit installation on a 32bit distribution or trying it with the debian branch of mint. I helped Richard Betson get to get bmax up and running on Debian and that was no picnick. And I see he's posted in another topic the same three lines that I have above near the bottom for Ubuntu 12.04. I already did that here. And at the time he posted I was just checking my emails on the ipad while I was tucked up in bed watching a film.

Believe it or not it's a lot simpler getting Monkey to work on any Linux distribution than blitzmax and the way things are looking with the number of updates for blitz max on Linux lately. Many could be wasting there time using blitzmax with Linux as nearly with every new updated distribution something will break.

In a few days I should have a bash script organised that will do the package 32/64bit installation/uninstall and patch/ install blitzmax with the updated alsa/pulse driver updates. Just trying to decide the if bmax should go into /options or user selected directory and setup some system links or add it to the paths variable in .profile.
I was thinking of updating the script in the dependencies, but you would still get people posting about the various issues that tend to crop.


Wiebo(Posted 2013) [#9]
@dawlane: Getting Monkey to work is easy, but I still have not gotten it to compile a GLFW target yet, and I found HTML performance to be.. ugh... I must admit, I have not tried again in a few weeks now.

And as where to place bmax: /opt is the 'official' correct place according to the linux file system specs, but oh well, we're not dealing with servers or multi-user systems here now are we? :)


dawlane(Posted 2013) [#10]
@Wiebo: You'll have to tell me what the problem is and what your linux rig setup is it could be a makefile problem as I found I had to link addtion libs; do it either in the monkey section or over at monkey coder save this thread just for bmax.
Monkey tends to be a bit picky when it come to browser performance with flash or html. I would put this down to the fact that there is still no conformity between browsers and html5 plus processing power would also be a factor. You tent to get the best performance with chrome.


Wiebo(Posted 2013) [#11]
Well, you started mentioning Monkey, I only reacted :)


dawlane(Posted 2013) [#12]
Well, you started mentioning Monkey, I only reacted :)
Ha Ha Ha. Did you get it to work yet?
Been meaning for a while to write a proper install script for Mint/Ubuntu that automated installation along with fixing stuff on the fly.
Well got an installer script working so far just need to write the patch code. Any one got ant thoughts on which should be the default sound driver?
The script gives you the choice of installing/removing the packages with BlitzMax and also the ability to remove the packages or BlitzMax individually.
It should be note that g++, build-essential and ia32-libs-multiarch will be left in case they are required by any other package. But then half of the packages installed would still be used so whats the point of removing all the packages.
The blitzmax installer by default will only allow the user who installed it have access to it (root is god and can go ant where) as if it can be used in a multi-user environment location (/opt) not the users home directory it would violate the license agreement.

EDIT: Using a patch file that's been copy&pasted into a text editor doesn't work.


dawlane(Posted 2013) [#13]
Double Post?


dawlane(Posted 2013) [#14]
Ok got an install script ready that will install the dependencies/BlitzMax+patch. So if you want to try it read on, but remember it's still a work in progress. And I may add the other distributions another time.
I have tested it on Linux Mint 15 32/64bit as that's what I use the most. It should work on 32 bit Mint. Also make sure that you have the archivers installed ( usually they are so if you can't extract a compressed file then you have't )

The script will need a bit of modification to work on Ubuntu 64bit as the shell has a problem with [ `name -m` == "x86_64" ] when run as sudo. When I get round to it I will fix it so that it will work on both Mint and Ubuntu running the script as sudo.

EDIT: 28/06/2013:
VERY IMPORTANT:
While testing on older linux distributon versions. I discovered the `who am i` doesn't work correctly on some distributions (Linux Mint 13 is one).
It is possible that you can trash your home directory if you run the install script as super user. So to check make a file on your Desktop named `test` and make it executable by right clicking the file and changing the execute checkbox.
Then copy and paste the code below into the new file, save it.
#!/bin/bash
WHO=$(who am i | awk '{print $1}')

if [ -z $WHO ]; then WHO=$SUDO_USER; echo "TRYING SUDO_USER"; else echo "who am i WORKS"; fi
if [ -z $WHO ]; then echo "NO USER"; else echo "USER IS $WHO"; fi
And open a terminal, change directory to the desktop and type sudo ./test. If the result is just your user name ( not root or multiple use names ) the everything should be OK.
If your not sure then use virtualbox with your distribution installed and set up the same way as your main system.

First make a new directory on your desktop and call it bmax-install and within this make six empty files using a text editor. Save each file exactly as

alsadevice.cpp
pulseaudiodevice.cpp
appstub.bmx
freeaudio.bmx
freeaudioaudio.bmx
bmax-install.sh

Add to this directory the compressed BlitzMax archive. The script will extract an archive named BliztMaxXXX_linuxx86.tar.gz (XXX being the version number)

credits to skidracer for ALSA, PulseAudio code and parts of the install script,

Now paste the code bellow for alsadevice.cpp

Next do the same for pulseaudiodevice.cpp

And again for appstub.bmx

And for freeaudio.bmx

Now for freeaudioaudio.bmx

And finally for bmax-install.sh


Now we need to make bmax-install.sh an executable file by changing its permission properties. Right click on the bmax-install.sh file and select properties from the context menu. You need to check the execute box in the permissions tab. You can also do it from the command line terminal by using
cd $HOME/Desktop/bmax-install
chmod -x bmax-install.sh


OK before you jump straight in and run it a few things first.

NOTE: If you find that you have problems with blitzmax applications running with the free drivers that come with the distribution then try and use one of the proprietary drivers.
You'll need to do a bit of googling to find out if your graphics hardware is supported as many of the proprietary drivers no longer
support old hardware.

The default sound driver selected is ALSA if you want to change it edit Freeaudio.bmx and Freeaudioaudio.bmx.

The locations are:
Freeaudio.bmx lines 66-75, lines 118-124
Just comment and uncomment for which you want to add or remove.
NOTE: in lines 118-124 change the value of the case statement to 0 for which ever one you use. If you're going to use all then just uncomment those lines, but leave the values as they are.

Freeaudioaudio.bmx lines 206-208
Again just comment/uncomment for which you want to use. And as before change the numeric value to match the one that was changed in the case statement in Freeaudio.bmx

These files in the BlitzMax directory that are to be replace are given the extension .bac so you can just do a bit of renaming to get them back.

In bmax-install.sh
If at some point the patching will not be needed then comment out lines 299,346.
And near the bottom ( lines 634-635 ) are two calls to remove any broken symbolic links. These are commented out by default just in case they remove something that they shouldn't on your machine but these do work perfectly on mine.

The script move the blitzmax modules directory to the installers home directory with the name 'blitzmods' and then a link is placed in /opt/BlitzMax to this directory. So removing BlitzMax will not remove the modules.

OK onto the fun stuff.

In a terminal that's set to the bmax-install directory.
type: sudo apt-get update
This makes sure that the packages are upto date.
Now type: ./bmax-install

You will then see all the options. The default is just to get the required packages so you can move BlitzMax and patch manually, but you will
have to do any system links yourself other than those that are created by default for the 64bit version of Linux.

The options:
-i : Installs all the packages and places BlitzMax into /opt and sets up links so that who ever did the install is the only one who can use it.
-u : Removes all the packages,links and BliztMax. But not build tools g++, build-essential and ia32-lib-multiarch for the 64bit.
-p : Just installs the packages and any links for the 64bit version of Linux.
-r : Just removes the packages and any links for the 64bit version of Linux.
-m : Just installs BlitzMax to /opt and set up links same as -i
-n : Just removes BlitzMax.

So typing: sudo ./bmax-install.sh -i
will install everything.

Once the script has been run and every thing has installed you will be able to start BlitzMax IDE from the command line using MaxIDE or maxide or use the link on your desktop. You can also use bmk from the command line too. Don't forget that you need to rebuild the module.


Derron(Posted 2013) [#15]
Just to add something: do not "chmod 777" the install script, just "chmod +x " to make it executable. Just a habbit :D.

Maybe you could consider storing the patch-file-data within the shell-file to keep it a single-file download. Then just echo-out the file content to the files.

echo 'start a new file' > file.txt
echo 'append to the file' >> file.txt

Easier and way more comfortable is something like:

#!/bin/bash

cat <<EOF >mynewfile.txt
the content
of this new file
is just placed
between the eofs
EOF

cat <<EOF >anotherfile.txt
bla
blubb
EOF


You could even write a shell script, which combines your install script with the "files" (just replace a "#CREATEFILES" from your install script with a "createfiles.sh"-content).


bye
Ron

PS: nice work!


dawlane(Posted 2013) [#16]
Hi Derron
Was thing of putting the patches into the scripts. But doing it the way that I've done it gives you the opportunity to edit the patch files first.
When I get round to it package management detection will use lsb_release as trying to determine using which is unreliable. I could possible use the /dev/null method.

Currently I'm messing around with OpenSUSE 64bit. What a nightmare it is. It maybe nice to use but trying to use any proprietary drives or system related is a waste of time. The hours just to get the pre-build nvidia drivers to download.
Ran the 32bit version in virtualbox all it needed was a few new packages, but it took a while to get it to compile on the 64bit version but the executables complained the GL could load something grabled xvideo.


Sub_Zero(Posted 2013) [#17]
For your script:

Ubuntu 13.04 / Kubuntu 13.04 builds modules out of the box with these dependencies (the 32-bit version):

sudo apt-get install libc6-dev
sudo apt-get install libx11-dev
sudo apt-get install libxxf86vm-dev
sudo apt-get install g++
sudo apt-get install mesa-common-dev
sudo apt-get install libxpm-dev
sudo apt-get install libfltk1.1-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libglu1-mesa-dev
sudo apt-get install libidn11-dev



dawlane(Posted 2013) [#18]
sudo apt-get install libidn11-dev
Hmmm something new. I will have to go through the dependencies as I'm sure libc6-dev is installed by default and libidn11-dev is for domain names etc.

When I get round to it I will be testing the first post script on Ubuntu 13 to see if it is still valid and see if I can tidy up some of the developer packages.

Thanks Sub_Zero

sudo apt-get install libfltk1.1-dev
Hold on doesn't the fltk module come with the fltk source code to build it's self? The modules current version is 1.3

In a day or so there will be a new script that for the time being that should work on Ubuntu 12.04, Linux Mint 15, openSUSE 12.3 and fedora 18.


Sub_Zero(Posted 2013) [#19]
The libidn might be baucause of some 3rd party module, sorry :)

woops you might be right about libfltk..


dawlane(Posted 2013) [#20]
Added a all-in-one patch script to the first post.

Sub_Zero:You don't need half of those packages.

Installing libglu1-mesa-dev installs libx11 etc.
For a basic package install for BlitzMax with MaxGUI you just need.

32bit
g++
64bit
ia32-libs-multiarch g++-multilib
Main packages
libglu1-mesa-dev libfreetype6-dev libxpm-dev libxft-dev
and one (or all) sound development package
libasound2-dev libpulse-dev libopenal-dev



Sub_Zero(Posted 2013) [#21]
Ok i always build modules, then on error i install the packages that contains the missing .h files :) then i rebuild again, so that's why i installed the packages in that order...

Oh by the way, libc6-dev was not installed in kubuntu by default.


Derron(Posted 2013) [#22]
@dawlane:

thanks for the "patcher script" - but if you think of changing the files someday you better use the "EOF"-style I wrote some posts ago. It is way better than
echo xyz >> file.txt
echo xyt2 >> file.txt
..


bye
Ron


dawlane(Posted 2013) [#23]
@Derron:Problem with using
cat > file <<EOF
blah,blah
EOF
Is that the end EOF is picky about having any characters in front of it on the same line. Tends to make code unsightly if it's a function doing the file making.


Derron(Posted 2013) [#24]
Yes... is is default for redirections (some may know it from php, it acts the same way).

But you can disable that behaviour (eg. for generating pretty/intended code):

Just use "<<-EOF" (dash/minus-sign), this tells the script to ignore tab-signs

For more information use: http://wiki.bash-hackers.org/syntax/redirection#here_documents


bye
Ron


dawlane(Posted 2013) [#25]
Yeah but wouldn't that screw up the text to the file it's outputting to? It would kind of make the resulting cpp file hard to read.
Edit: And Blitzploter had a problem with EOF from script-code that works flawlessly on mine.


Derron(Posted 2013) [#26]
There are no other signs allowed BEFORE and AFTER the delimiter used (that "EOF" is just a common word, others would be possible too).

@readability of files.
With comments say, it just ignores leading whitespace when searching the delimiter.

Please be aware that sometimes people leave " "-spaces after words. If you use Geany as editor, you can setup it to remove trailing whitespaces.

The "-"-dash sign might be not available on all "current" bash-versions but the normal
#!/bin/bash

#intention is no problem for ALL but the EOF-End-delimiter
				cat <<EOF >mynewfile.txt
	the content
		of this new file
			is just placed
				between the eofs
EOF


should be available when run with the bash interpreter.


There are people having the same problem like blitzplotter but they had ... signs in front or after the EOF-End-delimiter.

bye
Ron

edit: if you are not sure if you use reserved words ($1, $2...) in your code, you could add quotes around the first EOF (>>'EOF' or >>"EOF") - this should disable that variable recognition.

edit2: if you have the original upload (with EOF), please feel free to post it again for reference...I am quite sure, there is a simple character before or after the EOF.