Really ? One exe for all OS's supported by PB? Nothing else needed?

Everything else that doesn't fall into one of the other PB categories.
HoosierDaddy
User
User
Posts: 14
Joined: Wed Nov 23, 2022 12:51 am

Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by HoosierDaddy »

So, I'm still waiting on my laptop to get here and then I'll be ordering PB.
Question. Is it really true I can write a program in Windows and compile in Windows and it will also work on Linux or a Mac OS? Without jumping thru hoops ?! It just works? Call me skeptical. 🤣
I think I will only be writing for windows on windows, but it's amazing to me that it can be done if true?
Thanks in advance.
Tim.
Bitblazer
Enthusiast
Enthusiast
Posts: 730
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by Bitblazer »

It can not be done out of the box, but i regularly compile linux versions on my windows machine by using virtualbox. The same could be done for Mac OS.

You get a seperate compiler and IDE for each platform (32 and 64 bit), not a windows crosscompiler that creates linux or Mac binaries.
webpage - discord chat links -> purebasic GPT4All
User avatar
jacdelad
Addict
Addict
Posts: 1418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by jacdelad »

Since Linux and MacOS won't have much fun with exe-files natively, you can't. You need to compile it on the target system itself, or use a virtual machine.
BUT: The clou is, that one source code compiles for all OSes (excluding API calls (which are different on each OS, obviously) and very few commands which are limited by said OSes). In that case you can use the Compiler-commands to put in sections for a specific OS and by that really need one source for all.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by AZJIO »

How gravely wrong you are. Not only do you have to compile on each OS, but you also have to use conditions that will execute different pieces of code on different types of OS. In addition, for different types of Linux, you are better off compiling on the type on which the program will run. That is, the program may not work the same on older versions, or if you compiled on Fedora, but you need to run it on Mint or Arch.
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by mk-soft »

AZJIO wrote: Thu Dec 01, 2022 2:50 am How gravely wrong you are. Not only do you have to compile on each OS, but you also have to use conditions that will execute different pieces of code on different types of OS. In addition, for different types of Linux, you are better off compiling on the type on which the program will run. That is, the program may not work the same on older versions, or if you compiled on Fedora, but you need to run it on Mint or Arch.
That's why there are different FireFox versions ;)

For Linux I still compile under Ubuntu 20.04. So these also work from 20.04 up to currently 22.04 (or higher and all debian 11 versionen).
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
BarryG
Addict
Addict
Posts: 3266
Joined: Thu Apr 18, 2019 8:17 am

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by BarryG »

HoosierDaddy wrote: Thu Dec 01, 2022 12:54 amIs it really true I can write a program in Windows and compile in Windows and it will also work on Linux or a Mac OS?
The program's source code needs to be run on each OS (Windows, Mac, Linux) to create a program for that OS. So you're partly right: you write one source code, that generates three different OS programs when compiled on those OSes. But not one source and one output that runs the program instantly on all three. You can't create a program on Windows and then run it on Linux (except with Wine).
User avatar
spikey
Enthusiast
Enthusiast
Posts: 579
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by spikey »

The point is though that, if you do it right, you can have a single source tree that eventually produces output for all three OSes rather than having three separate source trees one for each variant which all require simultaneous maintenance (for application changes) and individual maintenance (for operating system specific changes). The larger the application the bigger and more time consuming this operation becomes.
Bitblazer
Enthusiast
Enthusiast
Posts: 730
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Really ? One exe for all OS's supported by PB? Nothing else needed?

Post by Bitblazer »

The advantage of this method is the execution speed of the final product and ability to use platform dependant special functions like the windows API on windows systems. Purebasic compiles into native executables instead of using a cross platform execution stack like Java does.

So you get the simplicity of a basic language without the basic language limitations as you can seamlessly use platform DLL's/Libraries and you can even include hand optimized assembler code if you need it.

"Write once and run anywhere" would be C or Java ;)

ps: it gets even better, the latest purebasic version 6 includes a C backend which uses the rock solid and very performant gcc compiler suite to build the final executable.
webpage - discord chat links -> purebasic GPT4All
Post Reply