compiling the PureBasic IDE on Linux

Linux specific forum
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

compiling the PureBasic IDE on Linux

Post by #NULL »

I'm trying to compile the PureBasic IDE on Ubuntu 18.04 x64. I copied Window-x64.cmd to Linux.sh and modified it but I don't know what gcc flags etc could be used so I get errors from g++. This is what I did so far:

Code: Select all

[user]~/Desktop>cd ~/Desktop/
[user]~/Desktop>mkdir pb_github/
[user]~/Desktop>cd pb_github/
[user]~/Desktop/pb_github>git clone https://github.com/fantaisie-software/purebasic
Cloning into 'purebasic'...
remote: Enumerating objects: 633, done.
remote: Counting objects: 100% (633/633), done.
remote: Compressing objects: 100% (554/554), done.
remote: Total 633 (delta 72), reused 629 (delta 72), pack-reused 0
Receiving objects: 100% (633/633), 3.48 MiB | 4.93 MiB/s, done.
Resolving deltas: 100% (72/72), done.
[user]~/Desktop/pb_github>cd purebasic
[user]~/Desktop/pb_github/purebasic>gedit Linux.sh 
Pasting the following in Linux.sh, save, exit editor:
(purebasic_570_lts_PBGITHUB is a copy of a normal pb 570 installation)

Code: Select all

#!/bin/bash

#:: Set the PureBasic home directory to a real x64 PureBasic installation (warning:
#:: when compilig, the IDE will be overwriten with the new one.
export PUREBASIC_HOME=/home/user/purebasic_570_lts_PBGITHUB


#set PB_VS8=C:/Program Files (x86)/Microsoft Visual Studio 12.0
#set PB_PLATEFORM_SDK=C:/Program Files/Microsoft SDKs/Windows/v7.0
#set PB_DIRECTX7_SDK=C:/Program Files (x86)/Microsoft DirectX 9.0 SDK (December 2004)
#set PB_DIRECTX9_SDK=C:/Program Files (x86)/Microsoft DirectX SDK (August 2009)


export PB_LIBRARIES=$PWD/Libraries
export PB_BUILDTARGET=$PWD/Build/x64


#set PATH=%PB_VS8%/VC/bin;%PATH%
#set PATH=%PB_VS8%/VC/bin/x86_amd64;%PATH%
#set PATH=C:/Program Files (x86)/Microsoft DirectX SDK (August 2009)/Utilities/bin/x86;C:\Program Files\TortoiseSVN\bin;%PATH%


export PB_PROCESSOR=X64

export PATH=$PUREBASIC_HOME/compilers:$PATH

#set PB_VC8_ANSI=cl.exe -I"%PB_VS8%/VC/include" -I"%PB_LIBRARIES%" -DWINDOWS -DVISUALC -DX64 -DPB_64 -D_USING_V110_SDK71_ -I"%PB_PLATEFORM_SDK%/Include" -I"%PB_PLATEFORM_SDK%/Include/crt" -I. -I"%PB_DIRECTX9_SDK%/Include" -I"%PB_DIRECTX7_SDK%/Include" /nologo /GS- /D_CRT_NOFORCE_MANIFEST
#set PB_VC8=%PB_VC8_ANSI% -DUNICODE
#set PB_NASM=nasm.exe -DWINDOWS -fwin64 -O3
#set PB_LINKER=link /LIBPATH:"%PB_PLATEFORM_SDK%/Lib/x64" /LIBPATH:"%PB_VS8%/VC/Lib/amd64"
#set PB_LIBRARIAN=lib /nologo
#set PB_LIBRARYMAKER="%PUREBASIC_HOME%/SDK/LibraryMaker.exe" /NOLOG /COMPRESSED /CONSTANT WINDOWS /CONSTANT %PB_PROCESSOR%
#set PB_IOFIX=
#set PB_OGREFLAGS=/MT /O2

#set PB_OGRELIBRARIAN=lib /NOLOGO
export PB_WINDOWS=0
export PB_OBJ=o
export PB_LIB=a

export PB_GCC_ANSI="g++ -I$PB_LIBRARIES"
export PB_OPT_SPEED=

#:: set a default subsystem
#set PB_SUBSYSTEM=purelibraries/

#echo Setting environment for PureBasic %PB_PROCESSOR%
#echo.


#:: If we don't specify any args, we want to open a CMD. Else we can use this script to setup an env for batching
#IF [%1]==[] GOTO opencmd
#
#GOTO end
#
#:opencmd
#
#cmd
#
#:end

now load the variables and continue with make:

Code: Select all

[user]~/Desktop/pb_github/purebasic>chmod +x Linux.sh 
[user]~/Desktop/pb_github/purebasic>source ./Linux.sh 
[user]~/Desktop/pb_github/purebasic>mkdir Build/
[user]~/Desktop/pb_github/purebasic>mkdir Build/x64
[user]~/Desktop/pb_github/purebasic>cd PureBasicIDE/
[user]~/Desktop/pb_github/purebasic/PureBasicIDE>cd PureBasicIDE/
bash: cd: PureBasicIDE/: No such file or directory
[user]~/Desktop/pb_github/purebasic/PureBasicIDE>make ide
cp -f data/ColorTable.xml /home/user/purebasic_570_lts_PBGITHUB/catalogs/ColorTable.xml
mkdir "/home/user/Desktop/pb_github/purebasic/Build/x64/ide"
touch /home/user/Desktop/pb_github/purebasic/Build/x64/ide/dummy
cp data/ToolsPanelRight.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/ToolsPanelRight.png
cp data/ToolsPanelLeft.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/ToolsPanelLeft.png
cp data/CloseButton.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/CloseButton.png
pbcompiler -q tools/pbpack.pb -e /home/user/Desktop/pb_github/purebasic/Build/x64/ide/pbpack 
/home/user/Desktop/pb_github/purebasic/Build/x64/ide/pbpack -q -l4 /home/user/Desktop/pb_github/purebasic/Build/x64/ide/images.pak data/startuplogo.png data/purebasiclogo.bmp /home/user/Desktop/pb_github/purebasic/Build/x64/ide/ToolsPanelRight.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/ToolsPanelLeft.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/CloseButton.png data/EmptySpace.png data/MissingIcon.png
make --directory ../DialogManager
make[1]: Entering directory '/home/user/Desktop/pb_github/purebasic/DialogManager'
mkdir "/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler"
touch /home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dummy
/home/user/purebasic_570_lts_PBGITHUB/compilers/pbcompiler -q DialogCompiler.pb -e /home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler 
make[1]: Leaving directory '/home/user/Desktop/pb_github/purebasic/DialogManager'
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Find.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Find.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Grep.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Grep.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Goto.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Goto.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/CompilerOptions.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/CompilerOptions.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/AddTools.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/AddTools.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/About.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/About.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Preferences.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Preferences.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Templates.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Templates.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/StructureViewer.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/StructureViewer.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Projects.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Projects.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Build.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Build.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Diff.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Diff.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/FileMonitor.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/FileMonitor.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/History.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/History.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/HistoryShutdown.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/HistoryShutdown.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/CreateApp.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/CreateApp.pb 
/home/user/Desktop/pb_github/purebasic/Build/x64/dialogcompiler/dialogcompiler dialogs/Updates.xml /home/user/Desktop/pb_github/purebasic/Build/x64/ide/Updates.pb 
cp ../PureBasicDebugger/Data/arrow.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/arrow.png
cp ../PureBasicDebugger/Data/select.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/select.png
cp ../PureBasicDebugger/Data/zoomin.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/zoomin.png
cp ../PureBasicDebugger/Data/zoomout.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/zoomout.png
cp ../PureBasicDebugger/Data/zoomall.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/zoomall.png
cp ../PureBasicDebugger/Data/cross.png /home/user/Desktop/pb_github/purebasic/Build/x64/ide/cross.png
rm -f /home/user/Desktop/pb_github/purebasic/Build/x64/ide/DefaultTheme.zip
zip -jq /home/user/Desktop/pb_github/purebasic/Build/x64/ide/DefaultTheme.zip data/DefaultTheme/*
mkdir "/home/user/purebasic_570_lts_PBGITHUB/themes"
mkdir: cannot create directory ‘/home/user/purebasic_570_lts_PBGITHUB/themes’: File exists
Makefile:247: recipe for target '/home/user/purebasic_570_lts_PBGITHUB/themes/SilkTheme.zip' failed
make: [/home/user/purebasic_570_lts_PBGITHUB/themes/SilkTheme.zip] Error 1 (ignored)
rm -f /home/user/purebasic_570_lts_PBGITHUB/themes/SilkTheme.zip
zip -jq /home/user/purebasic_570_lts_PBGITHUB/themes/SilkTheme.zip data/SilkTheme/*
pbcompiler -q tools/makebuildinfo.pb -e /home/user/Desktop/pb_github/purebasic/Build/x64/ide/makebuildinfo 
g++ -I/home/user/Desktop/pb_github/purebasic/Libraries  -c ../PureBasicDebugger/NetworkSupport.c -o /home/user/Desktop/pb_github/purebasic/Build/x64/ide/NetworkSupport.o
In file included from /home/user/Desktop/pb_github/purebasic/Libraries/Debugger/DebuggerInternal.h:33:0,
                 from ../PureBasicDebugger/NetworkSupport.c:30:
/home/user/Desktop/pb_github/purebasic/Libraries/PureLibrary.h:687:24: error: expected constructor, destructor, or type conversion before ‘SYS_UTF8ToAsciiLength’
 M_SYSFUNCTION(integer) SYS_UTF8ToAsciiLength(const unsigned char* in, integer inlen);
                        ^~~~~~~~~~~~~~~~~~~~~
/home/user/Desktop/pb_github/purebasic/Libraries/PureLibrary.h:688:24: error: expected constructor, destructor, or type conversion before ‘SYS_UTF8LengthToBytes’
 M_SYSFUNCTION(integer) SYS_UTF8LengthToBytes(const unsigned char* in, integer NbCharacters);
                        ^~~~~~~~~~~~~~~~~~~~~
/home/user/Desktop/pb_github/purebasic/Libraries/PureLibrary.h:696:30: error: ‘WCHAR’ does not name a type; did you mean ‘_T_WCHAR’?
 char  *SYS_UTF16ToUTF8(const WCHAR *String);
                              ^~~~~
                              _T_WCHAR
/home/user/Desktop/pb_github/purebasic/Libraries/PureLibrary.h:697:1: error: ‘WCHAR’ does not name a type; did you mean ‘_T_WCHAR’?
 WCHAR *SYS_UTF8ToUTF16(const char *String);
 ^~~~~
 _T_WCHAR
In file included from /home/user/Desktop/pb_github/purebasic/Libraries/Debugger/DebuggerInternal.h:33:0,
                 from ../PureBasicDebugger/NetworkSupport.c:30:
/home/user/Desktop/pb_github/purebasic/Libraries/PureLibrary.h:699:45: error: expected constructor, destructor, or type conversion before ‘SYS_StringToAscii’
 #define SYS_StringToAscii M_UnicodeFunction(SYS_StringToAscii)

[...]
[snip]
Anybody knows what PB_GCC_ANSI and PB_OPT_SPEED could look like? I tried gcc instead of g++, and -ansi.
These are the flags used on windows:

Code: Select all

set 
PB_VC8_ANSI=
cl.exe 
-I"%PB_VS8%/VC/include" 
-I"%PB_LIBRARIES%" 
-DWINDOWS 
-DVISUALC 
-DX64 
-DPB_64 
-D_USING_V110_SDK71_ 
-I"%PB_PLATEFORM_SDK%/Include" 
-I"%PB_PLATEFORM_SDK%/Include/crt" 
-I. 
-I"%PB_DIRECTX9_SDK%/Include" 
-I"%PB_DIRECTX7_SDK%/Include" 
/nologo 
/GS- 
/D_CRT_NOFORCE_MANIFEST
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: compiling the PureBasic IDE on Linux

Post by #NULL »

With the new version that Fred committed I created a file Linux-x64.sh from the OSX-x64.bash.
PUREBASIC_HOME is a [copy of a] pb installation. In there the IDE binary (compilers/purebasic) will be replaced during am IDE make (as well as the SilkTheme.zip). I removed the '/sw/bin/:' part from PATH because I think that's Mac specific. And I changed the DYLD_LIBRARY_PATH to LD_LIBRARY_PATH (not sure if that is used though).

Code: Select all

export PUREBASIC_HOME="/home/user/purebasic_570_lts_COPY"

export PB_PROCESSOR=X64

# set one of those (or none to default to gtk3)
#export PB_ENABLE_QT=1
export PB_ENABLE_GTK2=1

echo "Setting up purebasic basic environment $PB_PROCESSOR..."

export PB_LIBRARIES="$PWD/Libraries"
export PB_BUILDTARGET="$PWD/Build/x64"

export PATH="$PUREBASIC_HOME/compilers:$PUREBASIC_HOME/sdk/pureunit:$PATH"

# For OGRE
export LD_LIBRARY_PATH=$PUREBASIC_HOME/compilers:$LD_LIBRARY_PATH

mkdir -p Build/x64

. $PB_LIBRARIES/EnvironmentVariables.bash LINUX

I can now load this file and make the IDE:

Code: Select all

. ./Linux-x64.sh
cd PureBasicIDE/
make
If you now use the 'purebasic' command directly, it will open the IDE project with the actual IDE program that has just been compiled. So if you want to open the code in another version you might change PUREBASIC_HOME or open it another way.

Code: Select all

purebasic "PureBasic IDE.pbp"
When opened the project go to Compiler Options > Constants.
Change #BUILD_DIRECTORY to your build directory + ide/

Code: Select all

#BUILD_DIRECTORY=/home/user/Desktop/pb_github/purebasic/Build/x64/ide/
(use 'Set' button to save!)
Change #PureBasicPath to a pb installation (I just used the same as in the make config)

Code: Select all

#PureBasicPath=/home/user/purebasic_570_lts_COPY
In Compiler Options enter Subsystem 'gtk2'.
Now I can compile/run without the debugger. (It crashes here with debugger, both the compiling and the compiled IDE instance).
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: compiling the PureBasic IDE on Linux

Post by Fred »

Thanks for the update, glad you successfully compiled it ! Will add this script to the repo.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: compiling the PureBasic IDE on Linux

Post by #NULL »

Sounds good :)
Do you know if #PureBasicPath (from Compiler Options > Constants) is actually used? I can find only this:

Code: Select all

PureBasicIDE/PureBasic IDE.pbp:366:        <constant value="#PureBasicPath=/home/user/purebasic_570_lts_COPY" enable="1"/>
BUILD.txt:51:- The #PureBasicPath constant must point to a full PureBasic installation.
There are uses of PureBasicPath$, but not the constant.

Code: Select all

[user]~/Desktop/pb_github/purebasic>grep -HIrniE 'PureBasicPath[^$]'
PureBasicIDE/MacMisc.pb:152:  ;Debug "PureBasicPath: "+PureBasicPath$
PureBasicIDE/PureBasic IDE.pbp:366:        <constant value="#PureBasicPath=/home/user/purebasic_570_lts_COPY" enable="1"/>
PureBasicIDE/LinuxMisc.pb:122:  ;Debug "PureBasicPath: "+PureBasicPath$
BUILD.txt:51:- The #PureBasicPath constant must point to a full PureBasic installation.
Libraries/Debugger/DebuggerInternal.h:142:extern char  PB_DEBUGGER_PureBasicPath;
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: compiling the PureBasic IDE on Linux

Post by Fred »

Actually the code I did to handle this constant wasn't commited. I will put it again.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: compiling the PureBasic IDE on Linux

Post by #NULL »

Someone in the german forum was able to make the IDE with gtk2 but then can't start it because there are gtk2 and gtk3 symbols linked in purebasic:

Code: Select all

(purebasic:10506): Gtk-ERROR **: 10:50:03.669: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Any idea how this can happen?
User avatar
idle
Always Here
Always Here
Posts: 5089
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: compiling the PureBasic IDE on Linux

Post by idle »

I got the same error, can't see where it's coming from ?
(purebasic:24966): Gtk-ERROR **: 20:37:27.685: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Trace/breakpoint trap (core dumped)
[Idle@Idle-pc compilers]$
Linux-x64.sh

Code: Select all

#! /bin/bash
export PUREBASIC_HOME="/home/idle/purebasic571c"
export PB_PROCESSOR=X64
export PB_ENABLE_GTK2=1
echo "Setting up purebasic basic environment $PB_PROCESSOR..."
export PB_LIBRARIES="$PWD/Libraries"
export PB_BUILDTARGET="$PWD/Build/x64"
export PATH="$PUREBASIC_HOME/compilers:$PUREBASIC_HOME/sdk/pureunit:$PATH"
# For OGRE
export LD_LIBRARY_PATH=$PUREBASIC_HOME/compilers:$LD_LIBRARY_PATH
mkdir -p Build/x64
# we use -D_GNU_SOURCE to avoid __isoc99sprintf() etc. which is only glibc7
# we don't put -Winvalid-pch as we can temporarely put NO_UNICODE_ALIASES even for libs with precompiled headers
export PB_GCC_ANSI="gcc -D_GNU_SOURCE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -DLINUX -Wimplicit -fsigned-char -fno-ident -fshort-wchar -fno-optimize-sibling-calls -Wno-write-strings -Wno-pointer-sign -fno-stack-protector -Wno-deprecated-declarations -I$PB_LIBRARIES -D$PB_PROCESSOR"
export PB_GPP_ANSI="g++ -DLINUX -D_GNU_SOURCE -fPIC -fno-stack-protector -fsigned-char -fno-ident -fshort-wchar -Wno-write-strings -Wno-deprecated-declarations -I$PB_LIBRARIES -D$PB_PROCESSOR"
export PB_OGREFLAGS="-O2 -fvisibility=hidden -Wno-narrowing"
# We don't use -O3 for gcc, as it is known to be less performant in overall than -O2 (bigger code generation could not fit in small caches)
export PB_OPT_SPEED="-O2"
export PB_OPT_SIZE="-Os"
export PB_OBJ="o"
export PB_LIB="a"
export PB_OS="Linux"

if [ "$PB_PROCESSOR" == "X64" ]; then
	export PB_NASM="nasm -f elf64 -O3 -DLINUX"
	export PB_GCC_ANSI="$PB_GCC_ANSI -fPIC"
	export PB_GPP_ANSI="$PB_GPP_ANSI -fPIC"
else
	export PB_NASM="nasm -f elf -O3 -DLINUX"
fi

export PB_GCC="$PB_GCC_ANSI -DUNICODE"
export PB_GPP="$PB_GPP_ANSI -DUNICODE"
export PB_LINUX=1
export PB_ASM_HEADER="IncludeLinux"
export PATH=$PATH:$PUREBASIC_HOME/compilers
echo "Using GTK2"
export PB_GTK=2
export PB_INCLUDE="-DGTK_2 pkg-config --cflags gtk+-2.0"
export PB_SUBSYSTEM=subsystems/gtk2/purelibraries/
export PB_TARGET_POSTFIX=
export PB_LIBRARYMAKER="pblibrarymaker /NOLOG /CONSTANT LINUX /CONSTANT $PB_PROCESSOR /CONSTANT GTK2"

cd PureBasicIDE 
make ide

Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply