PDA

View Full Version : Compile on fedora, execute on Red Hat Enterprise Linux



edwardd20
5th July 2007, 01:51 PM
I apologize if this is answered elsewhere but I didn't find it.

My web hosting company is using a "64bit Single Intel Woodcrest 5130 Dual Core machine, with 4GB of RAM. The OS running is Red Hat Enterprise with with 2.6.19.2-grsec-sg5 kernel (i686 i686 i386 GNU/Linux). "

I need to be able to create a custom web script to demo my clients product.

I downloaded and installed Fedora 7 on my MacIntel (Core 2 Duo, MacBook Pro) using Parallels 3. I used the i386 DVD.iso installation. I created (and tested) an executable and then moved it over to my web server. On the web server it blows chunks with a Floating point exception.

Is this something I should be able to accomplish or do I need to get Enterprise just to create one executable?

Hopefully it is something dumb that I've done.

Ed

Reisswolf
5th July 2007, 02:03 PM
I believe the problem is that you are compiling in a 32-bit operating system and running the executable in a 64-bit environment.

The best way to accomplish this would be to download the x86_64 version of Fedora 7 and then compile your executables there.

edwardd20
5th July 2007, 02:09 PM
As I was posting this, I wondered if that could be the issue. I'll try again and report back. Thanks.

Gnafu the Great
5th July 2007, 03:23 PM
Also, you might have luck using CentOS (http://www.centos.org/) instead of Fedora, as it is made from RHEL's source. You'd still want to use the x86_64 version, but it might get you even closer. Since you have to reinstall anyway, you might as well get as close as you can (without having to purchase a license to RHEL).

edwardd20
5th July 2007, 07:28 PM
compiling in a 32-bit operating system and running the executable in a 64-bit environment.
I downloaded F7 x86_64 (4 hours) and discovered that Parallels doesn't support 64 bit OS's yet so I can't test it, let alone build it.

edwardd20
5th July 2007, 07:31 PM
Also, you might have luck using CentOS (http://www.centos.org/) instead of Fedora, as it is made from RHEL's source. You'd still want to use the x86_64 version, but it might get you even closer. Since you have to reinstall anyway, you might as well get as close as you can (without having to purchase a license to RHEL).

Really? I guess there is where my newbie status really shows. Red Hat Fedora isn't the same base code as Red Hat Enterprise Server?

Gnafu the Great
5th July 2007, 07:39 PM
Really? I guess there is where my newbie status really shows. Red Hat Fedora isn't the same base code as Red Hat Enterprise Server?

They share a lot, but I believe Fedora is more of a testing bed for new things to be implimented in RHEL, so it's actually newer. Their overall structure is essentially the same, but I just figure using CentOS will be more likely to work for you than Fedora, because it is exactly the same (aside from logos). There should be a way to compile for 64-bit in a 32-bit environment, but I have no experience with such a thing so I can't say. I know you can compile ARM on an i386 machine, so I don't see why not.

EDIT: And unless they have removed any and all i386 compatibility packages, I would think most 32-bit programs should still run in the 64-bit environment.

rjstaaf
5th July 2007, 07:44 PM
Fedora Core 6 is probably closer to RHEL 5 than Fedora 7 is(If they are running RHEL 5 and not an older version). I agree with what the other posters suggested, get CentOS as it IS RHEL...

edwardd20
5th July 2007, 07:55 PM
I'm downloading CentOS 5.0 (32 bit i386) version now. It says 8 hours. :(

lazlow
5th July 2007, 08:02 PM
I think that you need the 64bit version for what you want to do.

Gnafu the Great
5th July 2007, 08:07 PM
You might also want to try the Mac OS X port of QEMU (http://www.kju-app.org/kju/). It might allow you to run x86_64 guests.

edwardd20
5th July 2007, 08:11 PM
I think that you need the 64bit version for what you want to do.

I'm afraid of that but I can't run the 64 bit version.

edwardd20
5th July 2007, 08:12 PM
You might also want to try the Mac OS X port of QEMU (http://www.kju-app.org/kju/). It might allow you to run x86_64 guests.

Downloading now - I guess I'll have access to regular internet in about 24 hours, once I get done downloading all of these files. :rolleyes:

Gnafu the Great
5th July 2007, 08:14 PM
Downloading now - I guess I'll have access to regular internet in about 24 hours, once I get done downloading all of these files. :rolleyes:

I hope you have as much fun downloading large chunks of data as much as I do :D.

edwardd20
6th July 2007, 01:33 PM
I can report that compiling on CentOS 5.0 (32 bit) won't allow me to execute on RedHat 64-bit. :(

rjstaaf
6th July 2007, 01:39 PM
Probably time to talk to your host as 64bit RHEL should still support 32bit apps unless they have disabled it....

edwardd20
6th July 2007, 01:51 PM
Probably time to talk to your host as 64bit RHEL should still support 32bit apps unless they have disabled it....
But one question remains unresolved. Leaving 32 vs. 64 aside for now, "should" a Fedora or CentOS app run on RHEL or is there something different about the OS's that would prevent the cross-OS from working? Must I compile on RHEL to execute on RHEL?

I may have found myself access to a RHEL to do an actual compile but I won't know until Monday.

giulix
6th July 2007, 02:02 PM
Any compiler will produce, by default, executables able to run on the same processor architecture the compiler is running on. Some compilers, like gcc, are able to compile code for different processor architectures. For example, I can compile on my F7 x86 laptop code that will run on Solaris SPARC architecture. Such compilers are called cross-compilers. Just have a look at gcc options (if that's the compiler you're using)...

edwardd20
6th July 2007, 02:19 PM
Understood and that is what I expected which is why I'm confused why this isn't working.

My code consists of one C module and 8 C++ modules. The only I/O is in the C module and that is doing PRINTF's. So there "should" be nothing fancy that "should" prevent it from working. I'm linking with libstdc++ which is supposedly standard GCC and I would expect to be available on all platforms.

giulix
6th July 2007, 02:32 PM
Ok, so turns out all that is in theory. In practice, this (the ability to cross-compile) isn't compiled in in most distros. So, you'd have to recompile gcc. with binutils and a portion of the target C/C++ std libraries to get it to cross-compile.

See Wikipedia (http://en.wikipedia.org/wiki/Cross_compiler) for a short introduction on cross-compilers and gcc

sideways
6th July 2007, 02:54 PM
You could try static linking using the -static option with gcc, then the 64bit system doesn't need the 32bit shared libraries. You may have to install some devel-static packages to get the compile to work.

Building a 64bit cross-compiler looks like hard work, it would be simpler to just install a 64bit version of the target os.

giulix
6th July 2007, 03:01 PM
Or you can try and get a shell from here (http://www.ductape.net/~mitja/freeunix.shtml)...

edwardd20
7th July 2007, 04:24 AM
... try static linking using the -static option ...

sideways - you win the cupie doll. Apparently the web server on my ISP doesn't have the GCC runtime libraries available. Once I added -static (and the executable doubled in size), it runs fine.

So for the record, you can compile on 32-bit Fedora 7 (and CentOS) and execute on 64-bit RHEL.

Thanks to everybody for their help.

Ed

Gnafu the Great
7th July 2007, 05:17 AM
That's some handy knowledge; maybe I'll need it someday. I thank you, as well :D.