解决制作交叉编译工具链时报错“/libgcc.mvars: No such file or directory make”

当自己手动制作交叉编译工具链时,需要编译binutils,gcc等,其中编译过程绝对是很纠结的,一次通过的可能性不大,本文只针对一种类型的错误进行说明。

错误示例如下:

$ make

test -f config.h || (rm -f stamp-h1 && make stamp-h1) make[2]: Leaving directory /home/zql/build/arm64-toolchain/gcc/aarch64-branch/host-x86_64-unknown-linux-gnu/libcpp' make[2]: Entering directory/home/zql/build/arm64-toolchain/gcc/aarch64-branch/host-x86_64-unknown-linux-gnu/libdecnumber' make[2]: Nothing to be done for all'. make[2]: Leaving directory/home/zql/build/arm64-toolchain/gcc/aarch64-branch/host-x86_64-unknown-linux-gnu/libdecnumber' make[2]: Entering directory /home/zql/build/arm64-toolchain/gcc/aarch64-branch/host-x86_64-unknown-linux-gnu/gcc' make[2]: Leaving directory/home/zql/build/arm64-toolchain/gcc/aarch64-branch/host-x86_64-unknown-linux-gnu/gcc' Checking multilib configuration for libgcc... make[2]: Entering directory /home/zql/build/arm64-toolchain/gcc/aarch64-branch/aarch64-none-linux/libgcc' Makefile:161: ../.././gcc/libgcc.mvars: No such file or directory make[2]: *** No rule to make target../.././gcc/libgcc.mvars'. Stop. make[2]: Leaving directory /home/zql/build/arm64-toolchain/gcc/aarch64-branch/aarch64-none-linux/libgcc' make[1]: *** [all-target-libgcc] Error 2 make[1]: Leaving directory/home/zql/build/arm64-toolchain/gcc/aarch64-branch' make: *** [all] Error 2


        编译gcc时,需要注意一个原则:不要再gcc的源码中直接执行./configure、make、make install等命令,需要在源码目录下另外新建一个目录,在新建的目录中执行以上命令。

why?请看:http://gcc.gnu.org/install/build.html,为了防止该网址失效,我摘录重要部分如下:

If you encounter seemingly strange errors when trying to build the compiler in a directory other than the source directory, it could be because you have previously configured the compiler in the source directory. Make sure you have done all the necessary preparations.

  不要小看这个提示,好多错误都出自这里。好,问题有了,解决办法呢?很简单:假如gcc源码在/source目录下,

# cd /source

# mkdir build

# cd build

# ../configure....

# make...


以上指令的意思就是,在gcc的源码目录下新建一个目录,然后进入这个目录中执行configure,因为新建了目录,所以configure程序在上一个目录中,需要用".../configre"命令执行配置命令。

还有个需要注意的,如果编译一次报错了,没通过,需要执行make distclean清除以前的残留信息,或者干脆重新解压一份新源码再次编译。

Now,问题解决!



你可能感兴趣的:(解决制作交叉编译工具链时报错“/libgcc.mvars: No such file or directory make”)