工作主机:Debian10 64位
SDK包:MediaTek_APSoC_SDK5030_20170331.tar.bz2
一、安装gcc
解压toolchain/buildroot-gcc463_32bits.tar.bz2 , buildroot-gcc342.tar.bz2 到/opt目录下
**********************************************************************
二、安装LZMA
cd toolchain/lzma-4.32.7
./configure
make
make install
**********************************************************************
三、安装mksquashfs
cd toolchain/mksquash_lzma-3.2/
make
sudo make install
**********************************************************************
编译遇见的问题:
1.出错如下:
cc mksquashfs.o read_fs.o sort.o -L/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lpthread -lunlzma_r -llzma_r -lstdc++ -lz -o mksquashfs
/usr/bin/ld: mksquashfs.o: undefined reference to symbol 'log10@@GLIBC_2.2.5'
/usr/bin/ld: //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [<builtin>: mksquashfs] Error 1
make[1]: Leaving directory '/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools'
make: *** [Makefile:30: all] Error 2
+++++++++++++++++++++++++++++++++++++++++++++++++
解决:
在 toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/Makefile 中
mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ -lz 后面加上 -lm,修改如下:
mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ -lz -lm
+++++++++++++++++++++++++++++++++++++++++++++++++
继续编译!
2.出错如下:
cc mksquashfs.o read_fs.o sort.o -L/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lpthread -lunlzma_r -llzma_r -lstdc++ -lz -lm -o mksquashfs
/usr/bin/ld: mksquashfs.o: in function `create_inode':
mksquashfs.c:(.text+0x25a3): undefined reference to `major'
/usr/bin/ld: mksquashfs.c:(.text+0x25b0): undefined reference to `minor'
collect2: error: ld returned 1 exit status
make[1]: *** [<builtin>: mksquashfs] Error 1
make[1]: Leaving directory '/home/lgcdb/MTK/MTK_APSoC_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools'
make: *** [Makefile:30: all] Error 2
+++++++++++++++++++++++++++++++++++++++++++++++++
解决办法:
执行man major,发现major和minor函数需要包含头文件 #include <sys/sysmacros.h>
在toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/mksquashfs.c文件中加入#include <sys/sysmacros.h>
后面出现类似的错误,修改如下:
在toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/unsquashfs.c文件中加入#include <sys/sysmacros.h>
+++++++++++++++++++++++++++++++++++++++++++++++++
四、编译squashfs4.2
tar jxvf squashfs4.2.tar.bz2
cd squashfs4.2/squashfs-tools
make
sudo cp mksquashfs /opt/buildroot-gcc342/bin/mksquashfs_lzma-4.2
+++++++++++++++++++++++++++++++++++++++++++++++++
编译出错:
mksquashfs.c:1354:24: error: called object ‘major’ is not a function or function pointer
unsigned int major = major(buf->st_rdev);
^~~~~
mksquashfs.c:1354:16: note: declared here
unsigned int major = major(buf->st_rdev);
^~~~~
mksquashfs.c:1355:24: error: called object ‘minor’ is not a function or function pointer
unsigned int minor = minor(buf->st_rdev);
+++++++++++++++++++++++++++++++++++++++++++++++++
解决办法:
在mksquashfs.c中加入#include <sys/sysmacros.h>
类似的,
在unsquashfs.c中也加入#include <sys/sysmacros.h>
+++++++++++++++++++++++++++++++++++++++++++++++++
编译出错:
cc -O2 -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"xz\" -Wall -DGZIP_SUPPORT -DXZ_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT -c -o xz_wrapper.o xz_wrapper.c
xz_wrapper.c:28:10: fatal error: lzma.h: No such file or directory
#include <lzma.h>
^~~~~~~~
compilation terminated.
make: *** [<builtin>: xz_wrapper.o] Error 1
+++++++++++++++++++++++++++++++++++++++++++++++++
解决办法:
sudo apt-get install liblzma-dev
+++++++++++++++++++++++++++++++++++++++++++++++++