Page 1 of 3
Compile for foreign systems.
Posted: Wed Jul 13, 2011 8:22 pm
by GPI
At the moment i must run purebasic in the os-version, which i want to use. But it would be very usefull, when i coul compile a linux, macos, win64-Version under Win32.
Simple example - i have a programm for all this os - now i found a bug and it could be simple solved by a additional if-statement - nothing os specific code. But now i musst start every os, that i want support.
Or i want support macos - i found someone with a mac and he will test for me - but i cant create a testversion.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 11:07 am
by IdeasVacuum
I would like to be able to do so too, but I think it is just far too big a task for PB, especially given that all the OS's are moving targets. It's pretty well impossible to have 'neutral' code to suit all platforms anyway, you generally have to supplement your core code with platform specific bits and pieces to get it just right.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 11:13 am
by GPI
simple use compilerif #pb_compiler_os=#pb_compiler_os_windos (maybe the constant have other names) and you can specific code for the diffrent systems. Big parts of my code is os-independent - when i change something in this part, i must always boot the needed os...
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 6:30 pm
by freak
Sorry, not going to happen.
To be able to do this, every PB installation would need to include:
- the compiled libraries for all target platforms (simple, only takes some disk space)
- the pbcompiler with backends for all target platforms (again, rather simple)
- a cross-assembler for the target platforms (simple for linux as fasm can do this, not so simple for OSX)
- a cross-linker for the target platforms (didn't look into that one honestly)
- all required OS libraries of the target platforms to link against
The last one is the problematic one.
Lets take OSX:
We cannot ship OSX libraries with PureBasic for Windows because they are proprietary software. I don't think Apple would like that very much.
And Linux:
While this should be possible in theory its pretty much impossible in practice: We would need to include all binaries for gtk, sdl, libc, and many more including all dependencies in the PureBasic package. Not to speak of the fact, that these libraries don't exist in a cross-compilation ready fashion afaik. So while possible in the pure theory, we would be talking about a huge nightmare for us and a resulting PB installation that requires a DVD to fit, all so you can compile an executable that you cannot even test because you don't have the OS to run it on. That would be insane.
True cross-compilers generally only exist for embedded or mobile systems. I never saw one that can create GUI applications for a desktop system. The languages that do allow this are all using some form of bytecode-interpretion and do not produce native binaries as output.
You can run your target OS in a virtual machine, develop on Windows and even use the Windows debugger to connect to the program in the virtual machine. All you have to do is compile and run your program in the VM. Today's computers are fast enough for this and virtual machine software is available for free. I don't see the big problem in that.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 6:43 pm
by USCode
I believe RealBasic cross-compiles. How do
they do it?
http://www.realsoftware.com/
BTW, I am
not promoting RealBasic. I chose PureBasic over RealBasic as when I took a look at it several years ago because IMO I found several issues with RealBasic: big executables, buggy environment, expensive to license.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 7:09 pm
by ts-soft
USCode wrote:I believe RealBasic cross-compiles. How do they do it?
RealBasic creates no native exes, it is a form of bytecode-interpreter, big slow files

Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 8:05 pm
by idle
I noticed Realbasic has been working on an llvm front end but I have no idea if they've done it.
Apple are far to restrictive there goes the ihope and iwish
FYI I am writing a PB cross compiler, the code gen is 90% done and I'm just starting on wiring it into the parser
it will probably be a few months before its self hosting though.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 8:22 pm
by freak
As I explained, its not the compilation that is the real problem. If you want to do more than just printing stuff on the console, you are going to need libraries from the target OS to link against.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 8:33 pm
by idle
Yes it's not generally useful in itself and is generally used for targeting embedded platforms, for which you have the libs.
Apple have at least got it right with their tool chain.
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 8:35 pm
by USCode
ts-soft wrote:USCode wrote:I believe RealBasic cross-compiles. How do they do it?
RealBasic creates no native exes, it is a form of bytecode-interpreter, big slow files

That's not what they advertise:
http://www.realsoftware.com/realstudio/qualityapps.php
"Real Studio also compiles your code to native machine code for fast execution and to protect your intellectual property."
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 8:42 pm
by ts-soft
All native exe i can pack with for example UPX, but not the exe comes from RealBasic.
It is big, slow and not to pack with exe packers. I would not say the exe is nativ at all.
Many Text with object description in the exe ...
Re: Compile for foreign systems.
Posted: Thu Jul 14, 2011 10:53 pm
by MachineCode
The link above for RealBasic also states: "Real Studio applications do not have an interpreter or virtual machine, as its compiler generates machine code. This means that applications will look and act like native applications because they are, even if you created a Windows application from start to finish on your Mac."
So, assuming that's true, they probably had to pay a massive license fee (millions of dollars?) for each OS to allow it. I doubt Fred and Co have that kind of money to waste. And as Freak said, why code for Mac on a PC, if you don't have a real Mac to test it on? Nobody in their right mind would release a Mac app without actually testing it on a real Mac. That's just asking for trouble from your customers:
Customer: "Your app isn't doing what it's supposed to".
You: "Sorry, I haven't tested it on a real Mac, so I can't help."
Yeah, that's going to give you a great reputation as a coder/company.
Supporting cross-compilation sounds good "on paper" (ie. RealBasic's advertising), but in reality it's pointless.
Re: Compile for foreign systems.
Posted: Fri Jul 15, 2011 3:08 am
by netmaestro
RealBasic Website wrote:Real Studio Desktop Edition enables you to build stand-alone, native applications for Mac OS X, Windows & Linux. The drag and drop interface and object-oriented language abstract you from the code, letting you focus on building your application. You can even do a lot of your development without writing any code at all.
Please excuse me, I have a sudden strong urge to barf.
Re: Compile for foreign systems.
Posted: Fri Jul 15, 2011 4:26 am
by idle
Please excuse me, I have a sudden strong urge to barf.

Re: Compile for foreign systems.
Posted: Fri Jul 15, 2011 7:02 am
by freepurebasic
did you try guys to use:
lazarus
delphi 7 (still working on win 7/64 i already tested )
and freebasic (
http://freebasic.net/) ????
i already tested all these and all works