PureBasic Forum
https://www.purebasic.fr/english/

[solved] Run compiler from cmd on Linux, can't find OS Libs
https://www.purebasic.fr/english/viewtopic.php?f=15&t=70470
Page 1 of 1

Author:  Crusiatus Black [ Sat Mar 31, 2018 10:30 pm ]
Post subject:  [solved] Run compiler from cmd on Linux, can't find OS Libs

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:
Quote:
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

Author:  yuki [ Sat Mar 31, 2018 11:33 pm ]
Post subject:  Re: Run compiler from command line on Linux, can't find OS L

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:
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:
export PUREBASIC_HOME=/opt/purebasic/

Then anytime you want to compile:
Code:
$PUREBASIC_HOME/compilers/pbcompiler ~/Desktop/test.pb -e ~/Desktop/test.out

Author:  Crusiatus Black [ Sat Mar 31, 2018 11:53 pm ]
Post subject:  Re: Run compiler from command line on Linux, can't find OS L

Ah I must've missed that in the readme I believe. Thanks, that did the trick!

Author:  Sicro [ Sun Apr 01, 2018 12:21 am ]
Post subject:  Re: Run compiler from command line on Linux, can't find OS L

Type this in the terminal:
Code:
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.

Author:  Marc56us [ Sun Apr 01, 2018 9:57 am ]
Post subject:  Re: Run compiler from command line on Linux, can't find OS L

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:
$ echo $SHELL
/bin/bash
Then read the man page (ie: man bash) to know the configuration files used by the shell ($ man bash)

:wink:

Author:  Crusiatus Black [ Sun Apr 01, 2018 1:01 pm ]
Post subject:  Re: Run compiler from command line on Linux, can't find OS L

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

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/