1. 程式人生 > >解決製作交叉編譯工具鏈時報錯“/libgcc.mvars: No such file or directory make”

解決製作交叉編譯工具鏈時報錯“/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等命令,需要在原始碼目錄下另外新建一個目錄,在新建的目錄中執行以上命令。

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,問題解決!