Am I correct that while making a small linux system for an embedded device, we need kernel build based on the configuration set with the default toolchain. Whereas rootfs requires a toolchain ? Since the architecture is set in kernel there is no need of toolchains. Whereas the busy box makes a binary. Thus, it needs a toolchain. Please correct me as i have a doubt here.
问题:
回答1:
Toolchain plays very important role in embedded system development. In compiling and building also you required cross tool chain that is specific to your Architecture.Tools chain will not be default.You have to set it during configuration or while passing make command you have specify your tool chain prefix.
make CROSS_COMPILE=arm-none-linux-gnueabi-
The same tool chain should be used in compiling and building your Busybox. If you compile busybox with
statically.Then no need to worry about shared library. But if you compiled busy box with dynamically then your toolchain plays important role in rootfs. here you need to copy libraries of toolchain to rootfs /lib
folder .
what are the library need to be copied can be known just type following command.
strings _install/bin/busybox | grep ^lib
shows list library that should be kept in /lib
of your rootfs.
This command says, “Get all the strings from the file, and only show the lines that begin with lib.” The program ldd can’t be used, because the program has been cross-compiled and won’t run on the development host. These files should be fetched from the sysroot directory of the toolchain. Most modern toolchains have been configured with a sysroot, which is a directory that contains the files from the toolchain likely to appear on a root file system of a system targeted by the toolchain. To check if your toolchain has sysroot support, try the following:
$ arm-linux-gcc -print-sysroot
/arm-unknown-linux-gnueabi/bin/arm-linux-gcc If this is a valid path, this is where the files should be copied from. If no path is displayed, use find to locate a sysroot directory in , or use find to look for libc.so:
$ find . -name libc.so
After you’ve located libc and libm, create the (your rootfs)/lib
directory and copy them there. The files
are likely symlinks to other files, so be sure to gather them all. The next file to get is the dynamic loader,
normally called ld-linux-, which also resides in the lib directory along with libc.so.*.
Copy that to the /lib
directory. Your system now has all the shared libraries and the loader, so
BusyBox can run.
So finally if you want to compile any apps or program you should have to compile with this tool chain which you compiled busybox.
回答2:
--sysroot=dir
This option specifies the root directory where headers and libraries are located. when you give
(gcc) -print-sysroot
This will shows respective gcc(if its standalone tool chain) to look header and libraries to that particular directory .
While building stand alone cross-tool-chains at the time building and compiling gcc ,--sysroot=dir is given to finding respective include and library file.
you can see here configuration
cd $CLFS_SRC
tar -jxvf gcc-4.7.0.tar.bz2 && mkdir -v gcc-build && cd gcc-build
AR=ar LDFLAGS="-Wl,-rpath,${CLFS_CROSS_TOOLS}/lib" \
../gcc-4.7.0/configure --prefix=${CLFS_CROSS_TOOLS} \
--build=${CLFS_HOST} --target=${CLFS_TARGET} --host=${CLFS_HOST} \
--with-sysroot=${CLFS_CROSS_TOOLS}
Generally this folder contain all your shared libraries.
回答3:
@Shreyas, you have an wrong interpretation. Toolchain is nothing but an cross compiler which cross compiles source, so that it can run on the processor architecture it is compiled for. Even kernel & bootloader is a c code and you want it to be ported on embedded board, need to cross-compile, you need toolchain to cross compile kernel & u-boot source. So toolchain is needed, it may be either u-boot bootloader, kernel, rfs (Busybox) and application.