Monday, October 12, 2009

Praposal For Tv Production

Virtualization with VirtualBox, Sun's platform

Compile and execute 32 bits application in 64 bits operating system : " The world is going towards 64 bits machines and operating system for personal computer, but there are still some libs and software only support 32 bits. Therefore in this transition period, there is a needs to support both 64 bits and 32 bits applications. Lately I been using x86_64 Fedora Linux. There are requirements for me execute some 32 bits binaries as well as compiling to produce 32 bits binaries.

First of all, I do not aware of any great different for me based on user experience while migrating from 32 bits to 64 bits Fedora. Maybe this is because the fedora repository is in the good shape, where everything that I had downloaded by using yum, will works perfectly. Until one day I downloaded some legacy projects from the 3rd party website, that piece of software comes with 32 bits libs which needs 32 bits compilation. I started to realized that the binaries that I had compiled in my 64 bits environment is not working at 32 bits OS even though I am using the legacy version of gcc 3.4 compiler. Fedora x86_64 allows you to run 32 bits software given that the dynamic libs is installed properly. I realized that my fedora does have two directories for lib, /lib and another one is /lib64 . When I am searching for a particular lib using yum, let say libxml2, I realized that yum is actually returns me both 32 bits and 64 bits result.

yum search libxml2 ... libxml2.i386 : Library providing XML and HTML support libxml2.x86_64 : Library providing XML and HTML support ...
By default if I execute “yum install libxml2″, yum will install the 64 bits one for me. In my case I want the 32 bits glibc, what I have to do is to specify the exact package name.

yum install libxml2.i386 After the installation, now I can run the 32 bits application that requires libxml2.

How about compiling 32 bits application in 64 bits operating system?

First of all, I need to make sure I had installed all the development packages of the 32 bits libs required. Let takes libxml2 as the example, I need to yum ‘libxml2-devel.i386′.
Next tell gcc that I am going to compile the codes into 32 bit binaries by specify the -m32 CFLAGS. Assume I wrote a simple hello.c.



Now I need to produce the binary that can be run under Red Hat es4. I know the default version of gcc for RHES4 is 3.4 which I need gcc34 in my fedora. ( I need to yum another package ‘compat-gcc-34.x86_64′ for that) . With that now I can compile the codes at my x86_64 fedora to produce binary that can run at RHES4.



gcc34 -m32 -o hello{,.c} -lxml2



Related Posts

compile c and c++ source code


There are plenty of c and c++ compiler under unix based operating system, but the most famous one should be GNU gcc comp...




sha-1 checksum


What is sha-1 checksum? I heard about md5 checksum, did sha-1 makes any different?

Sha-1 is another algorithm that is...




Bit shifting can be done in python just like in c


It was amazing to discover that I can do bit shifting in python just like in c, the syntax makes no different at all. Le...






"


0 comments:

Post a Comment