This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cross compiling linux apps


"Eric A. Ayer" wrote:

> >
> > "Eric A. Ayer" wrote:
> >
> > > You seem to be doing almost the same thing that I am doing with compiling the
> > > linux apps and such.  My goal is to make my own non-distribution.  In any case,
>
> > To build the cross-compiler you need binutils, gcc and glibc.
> > I will assume you have built and installed binutils for your target and installed
> > it in your path.  I never had any problems with binutils.  I installed with
> > prefix=/usr/local/gcc.
> >
> > * Make sure $prefix/bin is in your path. (eg. export
> > PATH=/usr/local/gcc/bin:$PATH)
> > * Unpack gcc and glibc somewhere (eg. /usr/local/src).
> > * Create some build directories (eg. /usr/local/build/gcc and
> > /usr/local/build/glibc).
> > * Go to the gcc build directory and configure (/usr/local/src/gcc/configure) using
> > the --with-header=/usr/local/src/glibc/include (I'm guessing the path but it
> > should be similar).  Also only enable the C compiler at this stage.  Use the
> > --enable-languages=c then make the cross compiler using "make LANGUAGES=c".  "make
> > install" should install the glibc headers into $prefix/$target/include.
> > * Now go to the glibc build directory and configure/build/install.  The libraries
> > should be put in $prefix/$target/lib.
> > * Now go back to the gcc build directory any other componets your desire. eg. c++,
> > fortran, java, objc.  This is optional.  You don't need the C++ compiler to build
> > the linux kernel or most apps.
> >
> > Hope this helps a little.
> > Brendan Simon.
>
> Yes, it does.  Looks like I won't need to actually compile glibc to get the
> headers, but I'm still a little unsure about whether I'll need compiled lib-
> raries when compiling gcc.  So far I have, but I have been compiling c, c++,
> and whatever other languages are there.

The libraries need to be compiled with the cross-compiler, therefore you need to build
the cross-compiler first.  The C compiler doesnot need a cross-compiled C library to
build, but other languages do.  So build the C only component of GCC and install it.
You can then build the C libraries and install them.  Then build the rest of the
language components you desire (C++, fortran, java, etc).


> When cross-compiling apps and things (utils), the directory of the target
> headers and target libs needs to be specified, correct?  Is that normally done
> at configure time, like for gcc, or is an environment variable set or overrid-
> den?

This can be a bit of a problem.  The compiler will automatically search in
$prefix/$target/include for headers and $prefix/$target/lib for libraries.   "gcc
-print-search-dirs" will tell you the built in search paths.  If configure and
Makefiles specify include and library paths with -I and -L, then it is most likely that
native headers and libraries will be found instead of the cross-compiled
headers/libraries.  The build will probably fail.  You will probably need to specify
extra flags for configure and/or Makefile.  You may even have to hack the Makefile to
setup the paths properly.  I hate doing this kind of thing as it is not very repeatable
and you have to make the same modifications again if you reconfigure.


> In any case, thankyou for your input, it has made a few things clearer.

No worries.  I'm still learning too.

Brendan Simon.




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]