(For installing Euphoria 3 on 64-bit Linux see 'euphoria/doc/linux64.doc'). Intro ===== FreeBSD and its derivatives, such as DesktopBSD, GhostBSD, MidnightBSD, TrueOS, NomadBSD & others (https://en.wikipedia.org/wiki/FreeBSD#Derivatives) is similar to Linux distributions yet different. The instructions here are tested on GhostBSD-20.08.04 but should work on FreeBSD and its other derivatives more or less the same. Remember that you have to set the PATH and EUDIR environment variables before you can use Euphoria 3.1.1, i.e. append the following code to "~/.profile" or "~/.bash_profile" or "~/.shrc" file, (depends on your system): # Set PATH so it includes the euphoria 3 bin directory (if it exists), # and user's private bin directory; and set EUDIR as well: if [ -d "$HOME/euphoria" ] ; then EUDIR="$HOME/euphoria" PATH="$EUDIR/bin:$HOME/bin:$PATH" export EUDIR PATH fi Option #1: ==================================================================== How to run Euphoria 3.1.1 on 64-bit & 32-bit FreeBSD and Derivatives ==================================================================== When you install 64-bit FreeBSD you may have the choice to install "lib32", if so - then enabling it will install the 32-bit libraries in '/usr/lib32' directory by default. Otherwise you should install "lib32" as follows: On a 64-bit FreeBSD system (or derivatives), type in Bash shell (you can choose to use Bash shell also on FreeBSD): uname -a The output will tell you what version of FreeBSD you are using, and whether it is a 32-bit or 64-bit system, for example: FreeBSD NomadBSD 12.1-RELEASE-p6 FreeBSD 12.1-RELEASE-p6 #0 r362946M: Sun Jul 5 20:05:48 UTC 2020 ich@riara.uni.cx:/usr/obj/usr/src/i386.i386/sys/NOMADBSD i386 or... FreeBSD shian-ghostbsd-pc 12.1-STABLE FreeBSD 12.1-STABLE GENERIC amd64 Look at the above examples: the FreeBSD version is "12.1". So let's download "lib32" to the current directory; Type in Bash (Replace "12.1" with YOUR version): sudo fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/lib32.txz Now let's extract 'lib32.txz' (it contains lots of 32-bit libraries, for gcc compiler as well); Type in Bash shell: sudo tar -xvpJf lib32.txz -C / Now the 32-bit libraries are installed on 64-bit FreeBSD system, and in particular 'libm' and 'libc' which are necessary for Euphoria 3.1.1. Problem (on 32-bit and 64-bit FreeBSD): --------------------------------------- When you try to run Euphoria 3.1.1 on 32-bit or 64-bit FreeBSD (with "lib32" installed) you may get similar error messages: ld-elf32.so.1: Shared object "libm.so.2" not found, required by "exu" and... ld-elf32.so.1: Shared object "libc.so.4" not found, required by "exu" This is because 'libm' and 'libc' are newer versions then the versions that Euphoria 3.1.1 needs (2 and 4). Solution: --------- Let's create links to these newer libraries (whatever number they may have on your system): On Bash type two commands: cd /usr/lib32 ls lib?.so.* The ls command on Bash shows us the following libraries in '/usr/lib32': libm.so.5 libc.so.7 libz.so.6 So now that we know the newer version (5 and 7), let's create links to them using the version numbers that Euphoria 3.1.1 needs (2 and 4): cd /usr/lib32 sudo ln -s libm.so.5 libm.so.2 sudo ln -s libc.so.7 libc.so.4 Done. Now that "lib32" is installed and we created links to the newer versions in '/usr/lib32' directory, you can run 'exu'. :-) For C programmers... How to compile a c file into a 32-bit shared library, on a 64-bit FreeBSD and Derivatives, for Euphoria 3.1.1 open_dll(): =================================================================== Problem: -------- When you try to compile 'euphoria/demo/linux/Mylib.c' into a shared library, on a 64-bit FreeBSD, with: gcc -shared Mylib.c -o mylib.so you may get the following or a similar message: /usr/local/bin/ld: /tmp//ccd5jjqG.o: relocation R_X86_64_PC32 against symbol `extra' can not be used when making a shared object; recompile with -fPIC /usr/local/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status This is because gcc needs the 32-bit libraries for 64-bit FreeBSD system. Solution: --------- First, install gcc (if not already installed...), type in Bash: sudo pkg install gcc or... sudo pkg install lang/gcc Now you have to install the gcc 32-bit libraries... for this you should install "lib32" as described above (on top). Then use the -m32 flag to compile your file into a shared library: gcc -m32 -shared Mylib.c -o mylib.so Now you can run 'euphoria/demo/linux/mylib.exu' using mylib.so. Option #2: ==================================================================== How to run the *Linux* version of Euphoria 3.1.1 on 64-bit & 32-bit FreeBSD and Derivatives ==================================================================== These days the FreeBSD kernel (and its derivatives) also supports Linux applications *natively*, therefore you can choose to run the *FreeBSD* version of Euphoria 3.1.1 on a FreeBSD system or the *Linux* version of Euphoria 3.1.1 on a FreeBSD system. It's up to you, yet the installation of the 32-bit libraries for *Linux* (on FreeBSD) is different then for FreeBSD. If you try to run the *Linux* version of Euphoria 3.1.1 'exu' on 64-bit FreeBSD you will get an error message similar to this one: ELF interpreter /lib/ld-linux.so.2 not found, error 2 Abort trap So you must add support for 32-bit *Linux* applications on FreeBSD. To install support for 32-bit *Linux* applications on FreeBSD, do the following steps ( See also https://www.freebsd.org/doc/handbook/linuxemu.html ): 1. First you must load the 32-bit Linux kernel module (if it's not already loaded by default), type on bash shell: sudo kldload linux ( BTW, for 64-bit compatibility you had to type: 'kldload linux64' ). 2. To verify that the Linux module is loaded type: kldstat The output will be similar: Id Refs Address Size Name ... 12 1 0xffffffff8353f000 3cfc0 linux.ko 13 3 0xffffffff8357c000 3308 linux_common.ko 14 1 0xffffffff83580000 34e60 linux64.ko ... 3. Install a *base* set of Linux libraries and binaries on a FreeBSD system, using the 'emulators/linux_base-c7' package (a big package); Type in bash: sudo pkg install emulators/linux_base-c7 3.1 Now you may get a "Message from linux_base-c7-7.8.2003_1:" after the installation of 'linux_base-c7' package, so please use 'sudo' to open an editor and add the following lines where or if needed (this is just an *example* message): -- Some programs need linprocfs mounted on /compat/linux/proc. Add the following line to /etc/fstab: linprocfs /compat/linux/proc linprocfs rw 0 0 Then run "mount /compat/linux/proc". Some programs need linsysfs mounted on /compat/linux/sys. Add the following line to /etc/fstab: linsysfs /compat/linux/sys linsysfs rw 0 0 Then run "mount /compat/linux/sys". Some programs need tmpfs mounted on /compat/linux/dev/shm. Add the following line to /etc/fstab: tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777 0 0 Then run "mount /compat/linux/dev/shm". 4. For Linux compatibility to be enabled at boot time, add this line to /etc/rc.conf (using 'sudo' to open the editor as admin): linux_enable="YES" Note: On 64-bit machines, /etc/rc.d/abi will automatically load the module for 64-bit emulation. (Yet we need 32-bit emulation for Euphoria 3.1.1). 5. Logout and Login again to apply the new changes. Done. Now you can run the *Linux* version of Euphoria 3.1.1 on a 64-bit FreeBSD system :-). No additional Linux libraries are necessary for Euphoria 3.1.1 (Euphoria 3.1.1 for Linux/FreeBSD is based on libc & libm libraries, right?). P.s. In case that you must install additional Linux libraries, please read in https://www.freebsd.org/doc/handbook/linuxemu-lbc-install.html the section "10.2.1. Installing Additional Libraries Manually". For C programmers... How to compile a c file into a 32-bit *Linux* shared library, on a 64-bit FreeBSD and Derivatives, for Euphoria 3.1.1 open_dll(): =================================================================== You could probably install gcc for *Linux* on FreeBSD, yet I guess that it's better to create your *Linux* program on a Linux system, including any shared library, and then run it on 32-bit/64-bit FreeBSD as described above. :-) See also 'euphoria/doc/linux64.doc' (from Lib2 1.41) to understand how to create a 32-bit shared library on 64-bit Linux. Shian.