交叉編譯parted命令bug記錄
Linux parted命令編譯
parted原始碼在上個隨筆中已記述相關程式碼下載方法(ftp:https://ftp.gnu.org/gnu/parted/) 可以下載到想要的版本,還需要使用到libuuid,e2fsprogs等庫,當這些庫按照編譯命令編譯後得到對應的lib和標頭檔案。
libuuid相關程式碼下載和安裝可參考https://blog.csdn.net/qq_41622776/article/details/107639794,按照部落格使用的方法,parted3.2版本編譯到現有平臺會出現以下問題:
編譯命令為CFLAGS=-I/home/linux_parted/e2fsprogs-master/arch/include/ LDFLAGS=-L/home/linux_parted/e2fsprogs-master/arch/lib CC=mips-linux-gnu-gcc ../configure --prefix=/home/linux_parted/parted-3.2/arch --host=mips-linux --host=mips-linux --disable-device-mapper --without-readline --without-readline --disable-shared --disable-nls --disable-dynamic-loading
../../libparted/arch/linux.c: In function 'dm_canonical_path': ../../libparted/arch/linux.c:2313:32: warning: implicit declaration of function 'dm_task_create'; did you mean 'timer_create'? [-Wimplicit-function-declaration] struct dm_task *task = dm_task_create (DM_DEVICE_INFO); ^~~~~~~~~~~~~~ timer_create ../../libparted/arch/linux.c:2313:48: error: 'DM_DEVICE_INFO' undeclared (first use in this function); did you mean '_SC_DEVICE_IO'? struct dm_task *task = dm_task_create (DM_DEVICE_INFO); ^~~~~~~~~~~~~~ _SC_DEVICE_IO ../../libparted/arch/linux.c:2313:48: note: each undeclared identifier is reported only once for each function it appears in ../../libparted/arch/linux.c:2316:14: warning: implicit declaration of function 'dm_task_set_major_minor' [-Wimplicit-function-declaration] if (!dm_task_set_major_minor (task, arch_specific->major, ^~~~~~~~~~~~~~~~~~~~~~~ ../../libparted/arch/linux.c:2319:14: warning: implicit declaration of function 'dm_task_run' [-Wimplicit-function-declaration] if (!dm_task_run(task)) ^~~~~~~~~~~ ../../libparted/arch/linux.c:2321:55: warning: implicit declaration of function 'dm_task_get_name'; did you mean 'ped_unit_get_name'? [-Wimplicit-function-declaration] char *dev_name = zasprintf ("/dev/mapper/%s", dm_task_get_name (task)); ^~~~~~~~~~~~~~~~ ped_unit_get_name ../../libparted/arch/linux.c:2324:9: warning: implicit declaration of function 'dm_task_destroy'; did you mean 'ped_disk_destroy'? [-Wimplicit-function-declaration] dm_task_destroy (task); ^~~~~~~~~~~~~~~ ped_disk_destroy ../../libparted/arch/linux.c: In function '_disk_sync_part_table': ../../libparted/arch/linux.c:2949:33: error: '_dm_add_partition' undeclared (first use in this function); did you mean 'add_partition'? add_partition = _dm_add_partition; ^~~~~~~~~~~~~~~~~ add_partition ../../libparted/arch/linux.c:2950:36: error: '_dm_remove_partition' undeclared (first use in this function); did you mean 'remove_partition'? remove_partition = _dm_remove_partition; ^~~~~~~~~~~~~~~~~~~~ remove_partition ../../libparted/arch/linux.c:2951:36: error: '_dm_resize_partition' undeclared (first use in this function); did you mean '_dm_remove_partition'? resize_partition = _dm_resize_partition; ^~~~~~~~~~~~~~~~~~~~ _dm_remove_partition ../../libparted/arch/linux.c:2952:50: error: '_dm_get_partition_start_and_length' undeclared (first use in this function); did you mean 'get_partition_start_and_length'? get_partition_start_and_length = _dm_get_partition_start_and_length; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ get_partition_start_and_length Makefile:1359: recipe for target 'arch/linux.lo' failed make[3]: *** [arch/linux.lo] Error 1 make[3]: Leaving directory '/home/linux_parted/parted-3.2/build/libparted'
Linux parted命令編譯問題思考:
1 程式碼parted3.2中已經有libparted原始碼了,在編譯目錄parted3.2/build下執行make會出現libparted目錄,此時Makefile執行編譯
make[3]: Entering directory '/home/linux_parted/parted-3.2/build/libparted' CC debug.lo CC architecture.lo CC device.lo CC exception.lo CC filesys.lo CC libparted.lo CC timer.lo CC unit.lo CC disk.lo CC cs/geom.lo CC cs/constraint.lo CC cs/natmath.lo CC arch/linux.lo
接著便是build/libparted/arch 目錄下linux.c中編譯過程中出現的未宣告函式直接呼叫導致的錯誤!使用meld命令對比parted3.2/build/libparted/arch/linux.c和parted3.2/libparted/arch/linux.c發現
parted3.2/build/libparted/arch沒有生成linux.c檔案,那麼反推到parted3.2/build/Makefile檔案編譯parted3.2/libparted/Makefile.am Makefile.in檔案生成.lo檔案,那麼問題究竟出在哪呢?
終於找到這篇部落格:
https://blog.csdn.net/u011924787/article/details/63251851?spm=1001.2101.3001.6650.16&depth_1-utm_relevant_index=19
Linux parted中打個patch後還是有major/minor問題,參考https://blog.csdn.net/cinmyheart/article/details/21877487解決問題
順利解決問題!!
謝謝以上提及的部落格樓主們!!!