Page 1 of 1
Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 12:54 am
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.
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 1:10 am
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.
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 2:03 am
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.
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 2:50 am
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.
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 9:43 am
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).
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 12:18 pm
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).
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 12:28 pm
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.
Re: Really ? One exe for all OS's supported by PB? Nothing else needed?
Posted: Thu Dec 01, 2022 3:36 pm
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.