FreeBASIC development environment on Tiny Core LInux

Linux specific questions.
Post Reply
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

FreeBASIC development environment on Tiny Core LInux

Post by counting_pine »

Tiny Core Linux is a very lightweight distribution. Packages are stored in their own archives, and after booting you can choose to load only the packages you want to use. Your home folder is stored in a tarball, loaded at boot and saved on demand, so it's easier to avoid accumulating cruft.

I've been looking into getting FreeBASIC working on it, for something I can keep easily stored in a VirtualBox VM for easy access.

I've compiled these instructions on a bare 32-bit setup of Tiny Core Linux 9.0.
They should even work from a live environment, but I'd recommend a hard disk install, so that you have somewhere to save the downloaded packages and FreeBASIC source/binaries etc.

Packages in Tiny Core are installed with 'tce-load -wi package-names'. This saves the package to the hard disk, loads it now, and configures it load at next boot.
Alternatively, to not load the package on every boot, you can just download the package with 'tce-load -w ...', and load the package now with 'tce-load -i ...'

Here are the dependencies:

Code: Select all

# Packages needed to compile with fbc
tce-load -wi ncurses5 binutils gcc glibc_base-dev glib2

# Packages needed to compile fbc and its libraries
tce-load -wi make linux-4.14.3_api_headers ncurses-dev gpm-dev libX11-dev libffi-dev libGL-dev libXpm-dev libXext-dev libXrandr-dev

# git, for downloading new source code
tce-load -wi git

# Command-line niceties
tce-load -wi bash nano screen
My install is in /mnt/sda1, which is pretty standard. Here's my code for setting up the initial directories:

Code: Select all

# FB directory
FBDIR=/mnt/sda1/fb/
FBGITDIR=$FBDIR/fbc-git/

# create FB directory, make it writable
sudo mkdir $FBDIR
sudo chmod a+w $FBDIR
Here I download and extract a binary package of FB. Rather than installing it, I set up a simple alias 'fbc' to the downloaded binary:

Code: Select all

wget 'https://downloads.sourceforge.net/project/fbc/Binaries - Linux/More/FreeBASIC-1.05.0-linux-x86.tar.xz'
tar -C $FBDIR -xJf FreeBASIC-1.05.0-linux-x86.tar.xz

FBC=$FBDIR/bin/fbc
alias fbc=$FBC
I can now compile and run a simple "Hello World" app:

Code: Select all

echo 'print "Hello World!" ' > ~/hello.bas
fbc ~/hello.bas
~/hello # Hello World!
Now if I want I can download the latest source code, and make and test a new version of the compiler and runtime libraries.

Code: Select all

git clone https://github.com/freebasic/fbc.git $FBGITDIR

cd $FBGITDIR
make FBC=$FBC
I can now update my 'fbc' alias, and the new compiler is ready to use:

Code: Select all

FBC=$FBGITDIR/bin/fbc
alias fbc=$FBC

fbc ~/hello.bas && ~/hello # Hello world!
I can go on to test the new compiler with other make commands:

Code: Select all

cd $FBGITDIR
make clean-tests
make unit-tests FBC=$FBC
make log-tests FBC=$FBC
make warning-tests FBC=$FBC
(These may take a while, but are important for people who want to change the source code.)

Finally, I set my profile to set up $FBDIR / $FBGITDIR / fbc for me whenever I log in:

Code: Select all

echo 'export FBDIR=/mnt/sda1/fb/'        >> ~/.profile
echo 'export FBGITDIR="$FBDIR/fbc-git/"' >> ~/.profile
echo 'export FBC="$FBGITDIR/bin/fbc"'    >> ~/.profile
echo 'alias fbc="$FBC"'                  >> ~/.profile
And run Tiny Core's tool to back up my personal files to the hard disk so they are loaded at the next boot:

Code: Select all

filetool.sh -b -v
The final result, including all the package and source downloads and compiled binaries, should weigh in at under 350 MB.
The VM uses around 256 MB of memory at rest, so should comfortably run in 512 MB RAM.

I hope you find this useful.
I've revised these instructions retrospectively as I've gone along, so it would be good to see how someone finds working through them from start to finish.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC development environment on Tiny Core LInux

Post by coderJeff »

Perfect. Exactly what I needed.

In my use, the ISO was always used as the boot disk, and the window manager is always loaded by default.
Here's what I found (commands executed at a terminal, may need sudo):
To get started in Tiny Core, assuming I have just created a new VM with empty VHD.
- Boot from Tiny Core current ISO
- fdisk /dev/sda, create the primary partition, write, and exit
- Reboot
- mkfs.ext2 /dev/sda1
- mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1
- Reboot
- At the boot prompt, TAB, and append 'tinycore tce=sda1', this is the only time have to do this
- Reboot

I followed your instructions exactly:
But, to compile from fbc 1.05, I needed to change a few commands:

Code: Select all

cd $FBDIR
wget 'https://downloads.sourceforge.net/project/fbc/Binaries - Linux/More/FreeBASIC-1.05.0-linux-x86.tar.xz'
tar -C $FBDIR -xJf FreeBASIC-1.05.0-linux-x86.tar.xz

FBC=$FBDIR/FreeBASIC-1.05.0-linux-x86/bin/fbc
alias fbc=$FBC
Writing to ~/.profile sort of worked for me: Tiny Core boots in to the window manager by default, and FBC, FBDIR, FBGITDIR, alias fbc, are not yet defined. After I exit the WM to prompt, they are. When I '$ startx' to get back in to the WM, they are defined, but not alias fbc.

I have a windows share on my NAS, with repositories. To connect to this file repo:

Code: Select all

tce-load -wi cifs-utils
mkdir /mnt/repo
mount -t cifs //192.168.1.1/repo /mnt/repo -o username=jeff,password=PASS,sec=ntlm,vers=1.0
Then in fb git directory, I can use my LAN repo to transfer files/changes between virtual machines:

Code: Select all

cd $FBGITDIR
git remote add repo /mnt/repo/fb.git
Looks like Tiny Core also has LLVM pre-built packages. Will try those next.

Thanks counting_pine!
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: FreeBASIC development environment on Tiny Core LInux

Post by lizard »

If one wants to integrate Tiny Core in an existing bootmenu with Windows and few distros he can use grub-customizer:
viewtopic.php?f=5&t=26148&p=246179#p246179

this way:

Image

https://ibb.co/fgN0iy
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC development environment on Tiny Core LInux

Post by coderJeff »

After I build the new compiler (currently version 1.06 using 1.05), I'm lost as to what to do next. I normally only ever use the ENABLE_STANDALONE=1 version on win (sometimes dos). I am not very familiar with the 'prefix' installs of fbc.

I am trying to rebuild fbc with newly built fbc.

Do I need to ./install.sh the new fbc 1.06 to use it?
When I invoke /mnt/sda1/fb/fb.git/bin/fbc it doesn't find include directory, for example File not found, "file.bi" ..., when trying to recompile fbc.

EDIT:

What worked well for me, is to './install.sh -i' the fbc 1.05 version. Then after building 1.06, use 'make install' to update the installed version with the new compiler.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: FreeBASIC development environment on Tiny Core LInux

Post by counting_pine »

Hmm, maybe it is necessary to use install.sh first. I can't remember now..

After that, I'd sort of expect install.sh to take the place of 'make install'? (I'd actually forgotten the latter existed. In fact, maybe it's been a while since I built a full FBC on Linux...)

I'm presuming it's necessary to re-install FB whenever you restart Tiny Core. Although once a build is done, the 1.05 binaries shouldn't need to be installed first.

Interestingly there was a package for FreeBASIC in TinyCore 4.x: http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/
Associated threads: viewtopic.php?t=18925, http://forum.tinycorelinux.net/index.php?topic=11924.0

It would be interesting to see if a build for it could be automated. The package dependencies are at least a bit simpler now.
St_W
Posts: 1618
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FreeBASIC development environment on Tiny Core LInux

Post by St_W »

counting_pine wrote:It would be interesting to see if a build for it could be automated. The package dependencies are at least a bit simpler now.
In case there's any interest in it I could try to add a build configuration for my CI server to create nightly builds. (However, up to now the interest in non-Windows builds has been very low as it's quite easy to compile yourself due to the development environment dependecies being either already installed or easy to install)
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: FreeBASIC development environment on Tiny Core LInux

Post by counting_pine »

I think it would be most useful just to have a package of the latest official release (and future ones too).
So if we can work out a make task, that would allow that, and would make it easy for you to build if you wanted.

This topic might be helpful for more specifics on creating extensions:
http://forum.tinycorelinux.net/index.php?topic=18682.0

Looking at the package for TCC (Tiny C Compiler), we'd need to use /usr/local/{bin,include,lib} for the directory layout.

I worked out the list of basic dependencies it needs once its built: ncurses5 binutils gcc glibc_base-dev glib2

The package from the 4.x repos basically just contains 'FreeBASIC-0.23.0-linux.run' (I think that was basically a tarball with a prepended script), so it probably doesn't make a great model for scripting a package creation.
nimdays
Posts: 236
Joined: May 29, 2014 22:01
Location: West Java, Indonesia

Re: FreeBASIC development environment on Tiny Core LInux

Post by nimdays »

I had a problem with ncurses for 64 bit
http://forum.tinycorelinux.net/index.ph ... 35606.html
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC development environment on Tiny Core LInux

Post by coderJeff »

@nimdays, I had same problem with ncurses & freebasic on Slackware 14.2, 64-bit. Is it a FB issue? or an ncurses issues? The link you gave seems to indicate that FB should be linking with different ncurses library name on 64-bit? I don't know.
nimdays
Posts: 236
Joined: May 29, 2014 22:01
Location: West Java, Indonesia

Re: FreeBASIC development environment on Tiny Core LInux

Post by nimdays »

coderJeff wrote:@nimdays, I had same problem with ncurses & freebasic on Slackware 14.2, 64-bit. Is it a FB issue? or an ncurses issues? The link you gave seems to indicate that FB should be linking with different ncurses library name on 64-bit? I don't know.
I believe this is ncurses issue for 64 bit. No issue for 32 bit so far from my machine.
The link is for TC 7. For the latest TC 9 is here:
http://distro.ibiblio.org/tinycorelinux/9.x/x86_64/tcz
Post Reply