Page 1 of 1

calling pbcompilerc from command line in linux

Posted: Fri Dec 29, 2023 6:28 pm
by Yann64
Hi there

"~/purebasic/compiler" is in my $PATH (I can call pbcompiler and pbcompilerc from any directory), and I do manage to compile projects directly from the PB ide.

But, if I use

Code: Select all

pbcompiler main.pb -o ../bin/myproject -t -z -pf -dc
I get the following return :
PureBasic 6.04 LTS (Linux - x64)
Loading external modules...
Error: Can't load OS libraries, please re-install PureBasic.
And using

Code: Select all

pbcompilerc main.pb -o ../bin/myproject -t -z -pf -dc
I get the following return :
PureBasic 6.04 LTS - C Backend (Linux - x64)
Loading external modules...
Error: Can't load the 'c' subsystem.
I do not understand why it would work from the IDE and not from the command line.
Anybody can point me my (probably obvious) mistake?

Re: calling pbcompilerc from command line in linux

Posted: Fri Dec 29, 2023 7:17 pm
by mk-soft
Part of GitHub PureBasic IDE

A new bash is started with the correct path information.
After closing the bash, the path is also removed again and you can use a different path to pb.

Save as export_pb.sh und enable file property "Start as Program"

Update

Code: Select all

#!/bin/bash

# Test mandatory PureBasic path parameter
if [ -z "$1" ]; then
	echo "Invalid parameters: Missing argument for target PureBasic directory"
	exit 1
fi


# Set PUREBASIC_HOME and ensure compiler and IDE are in the PATH
export PUREBASIC_HOME=$1
export PATH="$PUREBASIC_HOME/compilers:$PUREBASIC_HOME:$PATH"

# Test if the PureBasic home is valid and check if this is PB or SB
if [ -f "$PUREBASIC_HOME/compilers/pbcompiler" ]; then
	
	# Start shell if the script is not sourced and PB_BATCH is not set
	if [ -z "$PB_BATCH" ] && [ "$0" = "$BASH_SOURCE" ]; then
		echo "Path set for target PureBasic directory $1"
		bash
	fi

else
	echo "Invalid path for target PureBasic directory"
	exit 1
fi
Terminal: change path!
./export_pb.sh /home/michael/Apps/purebasic-v610
pbcompiler -h
exit

Re: calling pbcompilerc from command line in linux

Posted: Fri Dec 29, 2023 9:39 pm
by Yann64
PUREBASIC_HOME must be set in order to call pbcompiler or pbcompilerc from the command line (forgot to do that).

Thanks for the help