LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-04-2007, 09:20 AM   #1
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Cross Compiling from i686 to i586 -- Necessary?


Hi,

I've been developing software for many years but I have never had to put much thought into cross-compiling from one architecture to another because the tools I needed were either provided by an outside vendor.

Therefore I would be grateful if somebody could help me answer these questions:

1) I assume that since I am developing on an i686 system running FC7 (or whatever) and my target is a 586MMX (i586), that I require a cross compiler. Is this correct?


2) If I use Kegel's (http://www.kegel.com/crosstool) cross-compiler builder suite, what do I do with the cross-compiler once it is built?

That may sound silly question but what I need to know is at what point am I ready to start building the binaries that I want to include with my deliverable? Do I need to dwell on making a suite of tools (similar to what is done in Cross-Compiled Linux From Scratch) that include binutils, gcc, etc. first and then, using those newly created tools, build my deliverables? Or can I just start building my deliverables?


3) Has anybody used 'ttylinux' (http://www.minimalinux.org/ttylinux)? Can I use it to cross compile from one arch to another?


4) Besides ttylinux, is there any other "minimal" Linux distro available? I do not require a development system for my deliverable -- just a basic system with a kernel, ncurses, busybox, glibc, gcc shared libraries, and a handful of other utilitarian tools.

The current distro I am attempting to build will include:
PHP Code:
busybox
dvdrtools
eject
expat
e2fsprogs
gcc
glibc
grub
hwclock
kernel
lockdev
ncurses
openssl
openssh
portmap
Qt
setserial
tinyxml
X11
xpm
xvkbd
zlib 
Thank you.
 
Old 09-05-2007, 05:44 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Yes, you need to build a cross compiler to start with. This will let you create the libraries and binaries for i586 from your running i686 system. If you were meaning to produce a new system which includes the ability to compile new programs for the new system, then the first thing you'd need to do with you cross-compiler is produce a native compiler for that system plus the necessary binaries for a development-capable system, including the shell, util-linux, coreutils, sed, awk etc.
Since your goal is a mini system this may not be what you want.
ttylinux will nowhere near meet your needs for compiling new software -all the binaries used in ttylinux are produced from another running system which is more complete.

But your posting is not clear on this -if you don't intend the deliverable system to be a development platform then why is gcc in the list. Also why do you need QT? If you start checking the dependencies of what you have listed you'll find that you need to add around 50-100 packages to your list already(many of these are covered minimally by busybox, but not all of them).
 
Old 09-05-2007, 09:23 AM   #3
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
gnashley -

Thank you for your response. Could you please help me understand this comment you made?

Quote:
This will let you create the libraries and binaries for i586 from your running i686 system. If you were meaning to produce a new system which includes the ability to compile new programs for the new system, then the first thing you'd need to do with you cross-compiler is produce a native compiler...
I have built a cross-compiler using the instructions given in the CLFS guide. As my target system is not going to be a development system, are you saying that all I need to do is use the cross-compiler to build the source packages that will run on the target system?

I am a little confused because the CLFS guide provides instructions for building GCC as a cross-compiler, then again for a "temporary system", and then a third time (native compiler??) for the final system. Do I need to build GCC as prescribed for a "temporary system" before I can begin building the packages to be included with my distro?

Btw, I am not fully aware of what dependencies are needed, and hence I am only following a working setup that is currently in use at my company. The gcc and Qt are included because they contain shared libraries that certain applications require during runtime. I guess the X11, tinyxml, and others are included for the same reason.
 
Old 09-06-2007, 07:43 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
If all you need are the gcc libs you wouldn't have to have the compiler itself as part of the deliverable. I suspect you'll be needing the libstdc++ libs as well as gcc.so since you are running Qt-based stuff. Anything written in C++ will need these.
You can produce all the programs from a 'foreign' platform if you want. The LFS intermediate or temporary stage is a very minimal, but bootable system used to produce the rest of the shared libs and binaries for a full system including the final compiler.
The reason for the several passes at compiling is that in the end everything on the new system should be compiled by/with/for/against the programs and libs of the new system. There are 'circular dependencies' between some libs and programs so mulitple passes are needed to resolve them.

In addition to the LFS docs, you might have a look at DIY linux. The process is much the same, but the documents being worder differently may help you to come to terms with it all. Don't feel bad if it causes you headaches while studying and doing thsi -that's perfectly normal. The fact that you are sticking to ix86 arches helpy a great deal and reduces the complexity of what you have to do.
 
Old 09-06-2007, 08:34 AM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Thank you again for your help and suggestions. I feel I understand a little more now concerning removing unwanted dependencies from my build. I've completed the minimal work environment as described per the CLFS guide, and now I am at the point where I will need to perform a chroot to start building the individual source packages necessary for my distro.

Upon examining the host.def file used by X11R6.9.0, I can see that there are many system dependencies that were originally taken for granted by the previous engineer assigned to the task I have been given. These will have to be built prior to any attempts to build X11. Undoubtedly similar issues are prevalent with the other source packages I must build as well.

This exercise is complicated in the sense that I must be able to easily reproduce all steps involved in creating the system using either build scripts or Makefiles, or a combination of both. Also not only do I have to account for the build environment, I also have to produce a Linux distro that will run on a bootable CD, and include the necessary applications to replicate the Linux distro onto a HDD should the operator choose to "install". This is a lot of work for just one person! I hope my company does not lose patience with my efforts.
 
Old 09-08-2007, 02:44 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I've been where you are before and wanted to do much thesame thing. So I hope you'll believe me when I tell you that you just described about 2 years of work -if your learning process progresses regularly. But don't think I mean you won't or can't get there or that I mean to discourage you.

Do write scripts for each phase of what you are doing(as much as possible -stuff you do in a chroot environment or that include reboots are hard to script). Write 3 times as many lines of comments (to yourself) as lines of code, so that you don't forget what you were doing last night or last week.

You probably begin to understand why most home-grown distros are simply off-shoots of existing distros. Even a very minimal self-contained distro capable of compiling itself consists already of up to 200 packages. For a bootable CD you'll have to create still another very tiny system for the initrd which is smart enough to find the main installation or create it.
Uisng busybox for your temporary/intermediate phases saves configuring and compiling many separate packages, but it's probably not a good idea to use these utilities in your end-product.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Should I have i586 or i686 on my system. toby50 Fedora - Installation 4 02-22-2007 10:22 AM
i586 i686 which one? soulxcavtor Linux - Software 8 05-28-2006 12:28 PM
i586 vs i686 alaios Linux - General 5 10-03-2004 10:01 PM
i586 or i686? nkarakos Linux - Newbie 2 10-03-2003 11:17 AM
I686 and I586? loganwva Linux - General 7 02-07-2002 06:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration