LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Cross-compiling applications? (https://www.linuxquestions.org/questions/linux-software-2/cross-compiling-applications-4175456969/)

littlebigman 04-05-2013 09:01 AM

Cross-compiling applications?
 
Hello

I checked the Documentation section on the Plug Computer site, but didn't find how to set up a cross-compiler on a PC running Linux, and compile an application for the SheevaPlug (armv5tel processor: Feroceon 88FR131 rev 1 (v5l)).

After upgrading the SheevaPlug from its stock Ubuntu 9.04 to Debian 6, I noticed that the latest release of Nginx is 0.7.67, while support for the uwsgi protocol requires release 0.8.40 or newer.

Is there a good tutorial on how to cross-compile on Linux for the SheevaPlug?

Thank you.

theNbomr 04-05-2013 08:51 PM

Before you start cross compiling, do you have a cross compiler (or, more accurately, a cross toolchain)? There are probably vendor supplied cross toolchains for the SheevaPlug; I'll let you explore that. Armed with enough knowledge of your target architecture, you can build your own. I like crosstool-NG for that.
Once installed, most applications that use the common 'configure' procedure allow you the choose the cross target architecture as a configure option; typically
Code:

#
PATH=$PATH:/the/path/to/your/cross/toolchain/binaries

#
#  One cross toolchain I use has binaries named like 'arm-unknown-linux-gnueabi-gcc'
#  The following will coerce the Makefile to have to appropriate prefix for all of the tools.
./configure --host=arm-unknown-linux-gnueabi

--- rod.

littlebigman 04-11-2013 06:39 AM

Thanks for the infos. The ARM architecture does seem to be complicated enough that a lot of people do need to build their own toolchain.

However, before I invest time in this, Marvell provides a binary toolchain: "Host SW Support Package For Linux".

After unzipping the file, I get two BZ2 files which untar into two directories: gcc/ and rootfsv1.0/, respectively:
Code:

~/LinuxHost# ll gcc
drwxr-xr-x  6 fred fred 4096 Feb 26  2008 arm-none-linux-gnueabi/
drwxr-xr-x  2 fred fred 4096 Feb 26  2008 bin/
drwxr-xr-x  3 fred fred 4096 Feb 26  2008 distributed/
drwxr-xr-x  2 fred fred 4096 Feb 26  2008 include/
drwxr-xr-x  2 fred fred 4096 Feb 26  2008 info/
drwxr-xr-x  3 fred fred 4096 Feb 26  2008 lib/
drwxr-xr-x  3 fred fred 4096 Feb 26  2008 libexec/
drwxr-xr-x  4 fred fred 4096 Feb 26  2008 man/
drwxr-xr-x  8 fred fred 4096 Feb 26  2008 share/

~/LinuxHost# ll rootfsv1.0/
drwxr-xr-x  2 root root  4096 Feb 26  2008 bin/
drwxr-xr-x  4 root root 36864 Feb 26  2008 dev/
drwxr-xr-x  3 root root  4096 Feb 26  2008 etc/
drwxr-xr-x  2 root root  4096 Feb 26  2008 lib/
lrwxrwxrwx  1 root root    11 Feb 25  2009 linuxrc -> bin/busybox*
drwxr-xr-x  2 root root  4096 Feb 25  2009 mnt/
drwxr-xr-x  2 root root  4096 Feb 26  2008 proc/
drwxr-xr-x  2 root root  4096 Feb 26  2008 sbin/
drwxr-xr-x 10 root root  4096 Feb 26  2008 usr/

I have a few more questions:
1. Running "gcc/bin/arm-none-linux-gnueabi-gcc -o hello hello.c" did compile a shared "Hello, world!" binary that I could run succesfuly on the SheevaPlug: How did the compiler know where to find the include + library?

Code:

~/LinuxHost/gcc/bin# file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped

SheevaPlug/tmp# ldd hello
        libc.so.6 => /lib/libc.so.6 (0x40004000)
        /lib/ld-linux.so.3 (0x2a000000)

Could it be that binaries are hard-linked to find includes + libraries?

2. "file hello" says "for GNU/Linux 2.6.14: Is it because the toolchain was built with that older release of Linux?

3. Why did Marvell provide a rootfs?

4. What should I do to compile real applications? Is it just a matter of editing PATH to include "/home/fred/LinuxHost/gcc" and using the right options in "./configure"?

Thank you.

theNbomr 04-11-2013 10:09 AM

I think these questions have been answered in a startlingly similar recent thread on LQ.

littlebigman 04-12-2013 07:45 AM

Yes, the first question was answered in that other thread :-)

What about the others?

2. "file hello" says "for GNU/Linux 2.6.14: Is it because the toolchain was built with that older release of Linux?

3. Why did Marvell provide a rootfs?

theNbomr 04-12-2013 11:48 AM

Generally, a toolchain gets built against a particular kernel version. That accounts for the result of the file command, I believe. In systems I've used, file also reports the CPU architecture of the specific executable.
The root filesystem is probably just a skeleton filesystem that is the sysroot for the toolchain, so it can find libraries, header files and ancillary toolchain components. Ideally, the sysroot files exactly match the respective target filesystem.

--- rod.

littlebigman 04-15-2013 12:46 AM

Thanks much.


All times are GMT -5. The time now is 08:11 PM.