# Linux Compatibility System and cross-compiling for Linux



## Anonymous (Mar 3, 2012)

Hi,

I am evaluating my options for providing CGI-executables written in C and compiled with gcc for Linux.

My preferred platforms are Mac OS X (client) and FreeBSD (servers), and I do programming for both. From Linux, I know only that it exists. Anyway, now I need to produce CGI-exec's for a web presentation that is run by a Linux hoster:


```
$ uname -a
Linux RHWEB100 2.6.18-274.12.1.el5 #1 SMP Tue Nov 8 21:37:35 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
```

Before I dive deep into Linux for this very limited purpose, I would like to check whether some cross-compiling options may work out. I checked already one option. I used an online compilation service for creating a simple "Hello, World!"-CGI, and it ran fine on said Linux host - of course, for production CGIs this is not an option.

I was thinking of using the Linux Compatibility System of FreeBSD and then create a cross compiling toolchain for producing the CGIs.

Could this work out?

If anybody did this already, please vote up!

Best regards

Rolf


----------



## ahavatar (Mar 3, 2012)

How about running the same Linux distribution of your client on a VM and compile your project there? Simply because the FreeBSD's Linux compatibility layer is based on Fedora 10, which is already old, and I'm not sure it is 100% binary compatible with other recent Linux distributions.


----------



## Anonymous (Mar 3, 2012)

ahavatar said:
			
		

> How about running the same Linux distribution of your client on a VM and compile your project there?



Well, I hoped I could ship around the reef of installing Linux somewhere.



			
				ahavatar said:
			
		

> Simply because the FreeBSD's Linux compatibility layer is based on Fedora 10, which is already old, and I'm not sure it is 100% binary compatible with other recent Linux distributions.



I see your point. Quick question: "Red Hat (free community) Linux is Fedora, isn't it?"

Many thanks for your reply.

Best regards

Rolf


----------



## ahavatar (Mar 3, 2012)

Yes, Fedora is RH's bleeding edge version that is free and changes like every 6 months.


----------



## expl (Mar 14, 2012)

You can compile linux binaries fine from FreeBSD by chrooting into your linux_base. The only issue is that you are limited to 32bit targets, it*'*s probably not what you want for production servers.


----------



## redw0lfx (Mar 14, 2012)

rolfheinrich said:
			
		

> Well, I hoped I could ship around the reef of installing Linux somewhere.
> 
> I see your point. Quick question: "Red Hat (free community) Linux is Fedora, isn't it?"



redhat's free community Linux is CentOS, which is actually used more by servers than Fedora, as it*'*s more stable, has longer support, and gets the same patches applied as Redhat Enterprise Linux.  Fedora is sort of the bleeding edge where new features are tested before being ported into RedHat Enterprise Linux and CentOS.  So compiling binaries on Fedora 16, won't always run correctly on Redhat Enterprise Linux or CentOS, as these are a few Fedora versions behind usually.

As for compiling directly on FreeBSD, I would suggest using VirtualBox or QEMU, and running a Linux Guest VM instead, since getting the necessary libraries/dependencies prepared can be a hassle.  At least, it was the last time I tried to compile Linux software on FreeBSD.


----------



## fonz (Mar 14, 2012)

expl said:
			
		

> You can compile linux binaries fine from FreeBSD by chrooting into your linux_base.


FreeBSD's Linux layer is based on Fedora 10, which is old. Chances are that the target system misses libraries, has other (possibly incompatible) versions of libraries, has another (possibly incompatible) kernel version and whatnot.

Fonz


----------

