Cross Compilation

New to FreeBASIC? Post your questions here.
iceblitzed
Posts: 3
Joined: Jan 28, 2014 22:32

Cross Compilation

Postby iceblitzed » Jan 28, 2014 22:35

Hello, I am using the FreeBasic computer language on a Windows-based computer(it is based on BASIC and has compability with Windows, Linux, FreeBSD, and DOS)

I am using an IDE called FBIDE to write and compile code.

Whenever I compile the code, the binary (executable) produced is only compatible on Windows-based computers

I looked up a web based compiler http://fbc.deltalabs.de/direct that can compile the code into a binary compatible on linux -based computers but I would like another way besides using a web based compiler.

Is there any easier way to guys might know of?
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Cross Compilation

Postby dkl » Jan 29, 2014 18:58

The easiest solution is to avoid cross-compilation and just take the source code to the target platforms and compile it there. It helps to use virtual machines (e.g. VirtualBox) to do that.

Cross-compiling is possible but usually much harder, as FreeBASIC is not fully set up for it out-of-the-box. Basically you need to get the proper cross-compiling binutils (as, ar, ld, dlltool, ...) in the bin/ directory, and all the target-specific libraries needed to link a program in the lib/ directory. Out of the box FB "only" comes with binutils and libraries for native compilation.

For example, on Debian GNU/Linux now I can install Debian's pre-packaged i686-w64-mingw32 gcc/binutils toolchain, and use that via fbc -target i686-w64-mingw32 ... to cross-compile Win32 programs.

However, on Win32 with FB-win32 it's typically much harder because getting pre-packaged gcc/binutils cross-toolchains is not as easy as installing them with an apt-get install... you either have to know some project that provides them for download, or built your own. And then you also need to get lots of target-specific libraries which typically means copying them from an existing install of the target system (or compiling the libraries manually, but that's way too much work). And if you have that, cross-compiling probably isn't worth it anymore.
iceblitzed
Posts: 3
Joined: Jan 28, 2014 22:32

Re: Cross Compilation

Postby iceblitzed » Jan 29, 2014 22:35

dkl wrote:The easiest solution is to avoid cross-compilation and just take the source code to the target platforms and compile it there. It helps to use virtual machines (e.g. VirtualBox) to do that.

Cross-compiling is possible but usually much harder, as FreeBASIC is not fully set up for it out-of-the-box. Basically you need to get the proper cross-compiling binutils (as, ar, ld, dlltool, ...) in the bin/ directory, and all the target-specific libraries needed to link a program in the lib/ directory. Out of the box FB "only" comes with binutils and libraries for native compilation.

For example, on Debian GNU/Linux now I can install Debian's pre-packaged i686-w64-mingw32 gcc/binutils toolchain, and use that via fbc -target i686-w64-mingw32 ... to cross-compile Win32 programs.

However, on Win32 with FB-win32 it's typically much harder because getting pre-packaged gcc/binutils cross-toolchains is not as easy as installing them with an apt-get install... you either have to know some project that provides them for download, or built your own. And then you also need to get lots of target-specific libraries which typically means copying them from an existing install of the target system (or compiling the libraries manually, but that's way too much work). And if you have that, cross-compiling probably isn't worth it anymore.


eh I might just have to dual boot linux what distro do you recommend
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Cross Compilation

Postby dkl » Jan 29, 2014 23:03

It doesn't matter for FreeBASIC, but I'd use OpenSUSE (that's what I used for the FB-linux release builds).
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross Compilation

Postby TJF » Jan 30, 2014 6:08

Hello iceblitzed, welcome to the forum!

iceblitzed wrote:eh I might just have to dual boot linux what distro do you recommend

In a dual boot configuration you can have only one system running at a time. When you use a virtual maschine as dkl proposed (ie like VirtualBox) you can run both systems simultaneously.

Also I recommend to check Geany IDE, running on both OSs.
iceblitzed
Posts: 3
Joined: Jan 28, 2014 22:32

Re: Cross Compilation

Postby iceblitzed » Jan 30, 2014 22:57

Ive heard something about dylibload (to load the external libraries dynamically) might be another option to look into. I am
not familar with this much

EDIT: Ive heard of MinGW too
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross Compilation

Postby TJF » Jan 31, 2014 7:47

Yes, an option to look into. There're more than 400 options to look into in the FB Wiki.

It meight be a good idea to learn how to compile an executable binary before you start with dynamic linked libraries.

Return to “Beginners”

Who is online

Users browsing this forum: MSN [Bot] and 2 guests