[solved] Run compiler from cmd on Linux, can't find OS Libs

Linux specific forum
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

[solved] Run compiler from cmd on Linux, can't find OS Libs

Post by Crusiatus Black »

Hi all,

I'm trying to run the PureBasic compiler from a terminal on an Ubuntu system which successfully compiles code from the IDE, however when run from the terminal the compiler outputs:
Error: Can't load OS libraries, please re-install PureBasic.
What's happening here? I should be able to run it from a terminal right?

PureBasic is installed in /opt/purebasic on my system and the user executing the command has full permissions on that directory.

PB 5.62 x64
Last edited by Crusiatus Black on Sun Apr 01, 2018 3:20 pm, edited 1 time in total.
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
User avatar
yuki
Enthusiast
Enthusiast
Posts: 101
Joined: Sat Mar 31, 2018 9:09 pm

Re: Run compiler from command line on Linux, can't find OS L

Post by yuki »

The compiler needs the PUREBASIC_HOME environment variable set, you you'll have to add it with SetEnvironmentVariable (if running through PB) or env/export in terminal.

Something like this should work:

Code: Select all

env PUREBASIC_HOME=/opt/purebasic/ /opt/purebasic/compilers/pbcompiler ~/Desktop/test.pb -e ~/Desktop/test.out
Alternatively, you can set the variable for the terminal session, instead of on each run:

Code: Select all

export PUREBASIC_HOME=/opt/purebasic/
Then anytime you want to compile:

Code: Select all

$PUREBASIC_HOME/compilers/pbcompiler ~/Desktop/test.pb -e ~/Desktop/test.out
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: Run compiler from command line on Linux, can't find OS L

Post by Crusiatus Black »

Ah I must've missed that in the readme I believe. Thanks, that did the trick!
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Run compiler from command line on Linux, can't find OS L

Post by Sicro »

Type this in the terminal:

Code: Select all

echo 'export PUREBASIC_HOME=/opt/purebasic' >> ~/.bashrc
echo 'export PATH=$PUREBASIC_HOME/compilers:$PATH' >> ~/.bashrc
This extends the file ".bashrc" with the necessary variable settings.

The file ".bashrc" is executed each time a terminal is opened. The settings are therefore still intact even after the system has been switched off or restarted.

Then you can simply enter "pbcompiler" or "purebasic" in the terminal, without the path.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Run compiler from command line on Linux, can't find OS L

Post by Marc56us »

Provided that this is bash the shell in use. This is usually the case on most Linux, but not always.
Let's remind beginners that there are multiple shells under linux/unix (bash, sh, zsh, ksh etc) and that you can change them at any time.
Each shell uses its own configuration files. (some are common)
The first file that is read from the Login is the profile file
Moreover each user can have his configuration files (they are in his "home dir" (~)) and are hidden (name begin with dot, so to see them: ls -a)
To know the shell in progress, type echo $SHELL

Code: Select all

$ echo $SHELL
/bin/bash
Then read the man page (ie: man bash) to know the configuration files used by the shell ($ man bash)

:wink:
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: Run compiler from command line on Linux, can't find OS L

Post by Crusiatus Black »

I know my way around Linux, but I don't always use bash indeed (as Marc56us stated). I was trying to make a build server for unattended nightly builds of a project I'm working on, however I simply forgot the environment variable. This build server uses multiple versions of PureBasic, so I set the environment variable each time I compile something to ensure the correct paths are set for every compilation.

Cheers
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Post Reply