Author Topic: Cross-compiling with QB64? (Writing Windows code on Linux)  (Read 3798 times)

0 Members and 1 Guest are viewing this topic.

Offline mackan

  • Newbie
  • Posts: 5
    • View Profile
Cross-compiling with QB64? (Writing Windows code on Linux)
« on: August 26, 2020, 07:48:45 am »
Hi!

As I understand it, the qb64 IDE / compiler pre-compiles to C, before (on Linux) compiling with gcc. Is there any way I can choose the compiler so that I can build windows binaries (.exe) with it? I know that GCC should be able to do this, but I don't seem to be able to pass any -m flags (-mwindows or -mconsole) to the gcc compiler from qb64 -c (or -x)

If it is not possible to either pass on compiler flags OR use different compilers (like mingw) - is there an installer of qb64 that can be installed under wine?

 

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #1 on: August 26, 2020, 09:18:34 am »
No, QB64 does not support cross-compiling. In theory the Windows version of QB64 should run in Wine (if only just as a command-line compiler), but I'm not sure if anyone's actually tried that before.

Offline mackan

  • Newbie
  • Posts: 5
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #2 on: August 26, 2020, 09:28:31 am »
OK - I tried to run it under the wineconsole and it runs and makes the first pass of the compilation (qb64 -z) but then something hangs. Is there a way to dig out the files created by qb64 (.exe) and compile them, using another compiler / make my own make script?

I mean - qb64 is already using gcc as the compiler, so it must be possible to make a workaround somehow...

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #3 on: August 26, 2020, 06:41:52 pm »
here a suggest
https://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation
I imagine that using a cross compiler you must use a common shared file system to copy the final executable from original compiler machine to destination machine. Do you confirm this ?

Programming isn't difficult, only it's  consuming time and coffee

Offline mackan

  • Newbie
  • Posts: 5
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #4 on: August 26, 2020, 07:19:33 pm »
here a suggest
https://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation
I imagine that using a cross compiler you must use a common shared file system to copy the final executable from original compiler machine to destination machine. Do you confirm this ?

I can use GCC as a cross-compiler, yes. That is not the problem. The problem is that I want to tell qb64 -c if it should compile to a native Linux binary or a Windows binary.

I am not sure I understand what you want me to confirm.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #5 on: August 26, 2020, 09:48:00 pm »
You can't cross compile with just a flip of a switch.  QB64 has a lot of distinct commands which translate completely into utterly different c-code depending on your operating system.

With Linux, you should be able to download a standard 32-bit version of QB64, and run it inside WINE to produce 32-bit Windows EXEs.

Even easier than that: Install Windows in a Virtual Machine, put QB64 in it, and compile there.

(For example, take the CONSOLE commands... Those all rely on native windows API calls.  There's no simple Linux substitute for them, so you're not going to set a -windows  flag to toggle over from the X11 calls and such for them.)
« Last Edit: August 26, 2020, 09:51:48 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline mackan

  • Newbie
  • Posts: 5
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #6 on: August 27, 2020, 08:03:17 am »
Thank you. I'll try that.

EDIT: Nope. Does not work. I am not sure, exactly, what does not work, though but it refuses to run under wine OR wine-console. Or rather - the IDE / Editor works fine. And it does the first step of the compilation. But then, when it should link the program (or - if QB64 is a pre-processor, compile the C-code) it crashes / hangs infinitely. Same behaviour regardless of I run 32 or 64 bit windows version in wine.

Ah, well.
« Last Edit: August 27, 2020, 11:24:39 am by mackan »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #7 on: August 27, 2020, 01:01:18 pm »
On my machine with native Windows upgraded to 10 I run Qb64 x64, moreover I have VM that has an emulated Ubuntu machine and I have installed a Linux version on that virtualized machine. There QB64, after the right settings, works well! When I write code that can be used on Windows and on Linux I compile on the two different machines to get the executable.

@mackan
my question is about the file system to use... Windows 10 uses NTFS, Linux uses FAT32 . I have no idea of how a file written in a file system can be copied into another file system, so my question is : "must you have the same file system on the compiling machine and on the executing machine? Or is the copy of the compiled file  a problem managed by the OS?
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #8 on: August 27, 2020, 01:05:39 pm »
about
Quote
For example, take the CONSOLE commands... Those all rely on native windows API calls.  There's no simple Linux substitute for them, so you're not going to set a -windows  flag to toggle over from the X11 calls and such for them.

So there is no a QB64 machine (like JVM) that the linker uses for the specific OS, but the compiler get C/C++ translation specific for the OS and compile it! This structure of the translator in C/C++ for now close the possibility to crosscompile! The translator will write code for the specific OS in which it is!
Thanks for this information.
Programming isn't difficult, only it's  consuming time and coffee

Offline mackan

  • Newbie
  • Posts: 5
    • View Profile
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #9 on: August 27, 2020, 01:53:29 pm »

@mackan
my question is about the file system to use... Windows 10 uses NTFS, Linux uses FAT32 . I have no idea of how a file written in a file system can be copied into another file system, so my question is : "must you have the same file system on the compiling machine and on the executing machine? Or is the copy of the compiled file  a problem managed by the OS?
[/quote]

Standard for Linux is EXT4, I think, but no - it should not make a difference. What wine does is setting up a virtual environment, of sorts, and it can't really see beyond some fixed mount points. All the files (including the source) is kept in the same directory and the IDE sees the source code etc. There is no reason for the compiler / linker to be anything other than filesystem agnostic, right?


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Cross-compiling with QB64? (Writing Windows code on Linux)
« Reply #10 on: August 27, 2020, 03:20:35 pm »
The translator will write code for the specific OS in which it is!

Yep.  In fact, if you even take a moment to look in the folder that contains the cpp files (libqb.cpp and such), you'll see we even have various config files and data files, which are specific to each OS.  QB64 translates OS specific code.  You can't just copy the internal/temp folder and move it to a different system and expect it to work.  Some simple code might, but anything that relies on specific Windows/X11 commands certainly won't. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!