Cross compiler default include path setup

2019-04-13 17:09发布

问题:

First, some background: I'm attempting to write drivers and applications for Android on the Beagleboard-xM.

I've downloaded their android development kit, installed it, and can succesfully build everything in it using the directions at http://processors.wiki.ti.com/index.php/TI-Android-ICS-4.0.3-DevKit-3.0.0_DevelopersGuide

I've been able to make my own skeleton kernel module following the steps in http://tldp.org/LDP/lkmpg/2.6/lkmpg.pdf without issues. I can copy the .ko file to the android device, insmod, rmmod, etc.

I got tired of the basic shell given by the default build and thought I'd add busybox. I tried following the directions at http://omappedia.org/wiki/Android_Installing_Busybox_Command_Line_Tools, but I get a compile error on standard libc header files.

After digging around quite a bit, I've determined that the pre-built cross compiler provided in the TI android development kit wasn't searching the right paths.

I confirmed this by creating my own .c file that included and tried to compile it with arm-eabi-gcc blah.c -o blah and was met with the same results (unable to find the header file in question)

'arm-eabi-gcc -print-prog-name=cc1' -v gives me this:

  • ignoring nonexistent directory "/usr/local/google/home/android/cupcake_rel_root/usr/local/include"
  • ignoring nonexistent directory "/usr/local/lib/gcc/arm-eabi/4.4.3/include"
  • ignoring nonexistent directory "/usr/local/lib/gcc/arm-eabi/4.4.3/include-fixed"
  • ignoring nonexistent directory "/usr/local/lib/../arm-eabi/include"
  • ignoring nonexistent directory "/usr/local/google/home/android/cupcake_rel_root/usr/include"

None of these paths ever existed on my fresh install of ubuntu 10.04. My cross compiler I used is at /usr/TI-Android/prebuilt/linux-86/toolchain/arm-eabi-4.4.3/. I didn't do anything except run the bit .bin file that was the android development kit (which seemed more like simply extracting itself from the .bin file; I don't remember it doing anything else)

So, a few questions:

  1. how the heck did everything else (i.e. android, x-loader, u-boot, the kernel) build by just putting the bin of the cross compile tool into $PATH (like the how-to documents say). I assume it (make menuconfig?) does some magic in fixing up the include paths based on the location of the executable, but...
  2. Why doesn't busybox work the same way since it seems to be built with a similar looking infrastructure?
  3. How do I make it so I can cross compile my own applications?

I assume I've missed a step and should have done some sort of install/configure on the pre-built cross compiler, but information is horribly scant. I appeal to you, open source gods, to point my way across this dark and stormy sea.

回答1:

For posterity, it seems that the prebuilt tools included with the android development kit are only enough to build the kernel and don't include libc or other library header files. (The NDK tools are 'different' and the build environment is even more different because it has its own version of libc--bionic. That build environment might have been able to build what I wanted, but I would have had to muck with Androidy makefiles, etc.)

I ended up having to get Code Sourcery arm-none-linux-gnueabi (must get the linux-gnueabi one to have the linux system header files needed), and everything worked reasonably smoothly after that.