On 08/23/2013 06:18 AM, Ian Craggs
wrote:
How would using automake/autoconf
help with cross-compiling? I've never used them, so I don't
know. I was under the impression that they helped if you had a
lot of dependencies, which these libraries don't - only gcc.
The "--build" and "--host" options to the configure script allow you
to set things up each time you compile. You set the build to your PC
and the host to the target platform/compiler, like:
./configure --build=i686-pc-linux-gnu --host=arm-eabi
By making them different, it knows that you're cross-compiling and
will use the compiler "arm-eabi-gcc", and so on.
You can also use the "--prefix" option to set the install directory,
so that you can have a bunch of different versions on your computer
(one for Raspberry Pi, one for Beaglebone, etc).
./configure --build=i686-pc-linux-gnu --host=arm-linux
--prefix=/opt/xlibs/arm-linux
If you compile natively on any platform, you don't worry about the
settings. Just:
./configure
After you configure, you run "make" and "make install", and the
libraries are where you requested.
I think the problem is that are so many combinations of
processors, EABIs, Linux or other Unix kernel levels, C
libraries and versions (uclibc as well as glibc for example),
that deciding on the targets we wanted to build for would be
impossible.
That's the beauty of this... You don't have to worry about the
different targets, assuming that they are Linux/gcc.
And it is very consistent across libraries. A very large percentage
of Linux libraries can be cross-compiled in this manner, whether or
not that was the author's intent. It just works.
If you are running an OS in the configuration you want, and you
have gcc, it is easy to build - at least for Linux/Unix. If I
want to compile for Pi or whatever, I clone the source with git
and make - job done.
With just a makefile, someone new would have to start searching
through the file to find out how to cross-compile. With a configure
script, it's consistent with much of the rest of the Linux world.
For Windows I prefer the Microsoft compilers, as in my
experience they produce better code. And most developers will
also be using Visual Studio. A Visual Studio project is the
obvious solution, no?
Recently I've been setting up Eclipse Hudson system to build and
test the C clients, for Linux 64-bit (see
https://hudson.eclipse.org/hudson/job/paho-c-dev-nightly/
- the test failures are because we're still setting up the SSL
test environment). I've used Ant, as that seemed to coexist
with Hudson nicely. Proliferating build methods, however,
doesn't seem desirable.
Agreed, this is only for Linux, mainly for gcc. Some other system,
such as Ant my encompass both. But most Linux C developers are
probably not familiar with using Ant.
Frank
|