編譯某基於openwrt的sdk

由於自己的linux系統比較新,導致編譯個基於openwrt的sdk問題多多,在此記錄解決過程

1.
問題:
freadahead.c: In function 'freadahead':
freadahead.c:91:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
   91 |  #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
      |   ^~~~~
make[7]: *** [Makefile:1837: freadahead.o] Error 1
make[7]: Leaving directory '/opt/p2/openwrt/build_dir/host/m4-1.4.17/lib'

解決:
cd /opt/p2/openwrt/build_dir/host/m4-1.4.17/
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

2.
問題:
lib/fseterr.c: In function 'fseterr':
lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
   77 |  #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
      |   ^~~~~
make[6]: *** [Makefile:3461: lib/fseterr.o] Error 1
make[6]: Leaving directory '/opt/p2/openwrt/build_dir/host/bison-3.0.4'

解決:
cd /opt/p2/openwrt/build_dir/host/bison-3.0.4/
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

3.
問題:
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.o: in function `write_special_file':
/opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:944: undefined reference to `major'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:944: undefined reference to `minor'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.o: in function `recursive_populate_directory':
/opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:1273: undefined reference to `minor'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:1273: undefined reference to `major'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:1263: undefined reference to `minor'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:1263: undefined reference to `major'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.o: in function `interpret_table_entry':
/opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:467: undefined reference to `makedev'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:503: undefined reference to `makedev'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c:510: undefined reference to `makedev

解決:
/opt/p2/openwrt/build_dir/host/mtd-utils-1.5.2/mkfs.jffs2.c 中添加#include <sys/sysmacros.h>


4.
問題:
  CC      ubi-utils/libubi.o
ubi-utils/libubi.c: In function 'vol_node2nums':
ubi-utils/libubi.c:383:10: error: called object 'major' is not a function or function pointer

解決:
此問題與3號問題相似,打開文件發現二者都有#include <sys/types.h>, 暴力點可以直接修改/usr/include/sys/types.h添加#include <sys/sysmacros.h>


5.
問題:
/usr/include/asm-generic/int-ll64.h:31:42: error: conflicting types for ‘__u64’
   31 | __extension__ typedef unsigned long long __u64;
      |                                          ^~~~~
In file included from <command-line>:
././include/compiler.h:69:18: note: previous declaration of ‘__u64’ was here
   69 | typedef uint64_t __u64;

解決:
修改build_dir/host/u-boot-2018.03/include/compiler.h
註釋或者刪除typedef uint64_t __u64;

6.
問題:
freadahead.c: In function 'freadahead':
freadahead.c:92:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
   92 |  #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
      |   ^~~~~
make[9]: *** [Makefile:2225: freadahead.o] Error 1
make[9]: Leaving directory '/opt/p2/openwrt/build_dir/host/findutils-4.6.0/gl/lib'

解決:
進入出錯目錄:
cd /opt/p2/openwrt/build_dir/host/findutils-4.6.0
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h
sed -i '/unistd/a #include <sys/sysmacros.h>' gl/lib/mountlist.c

7
問題:
hecking version of makeinfo... v. ?.??, bad

configure: WARNING:
*** These auxiliary programs are missing or incompatible versions: makeinfo
*** some features will be disabled.
*** Check the INSTALL file for required versions.
checking LD_LIBRARY_PATH variable... contains current directory
configure: error:
*** LD_LIBRARY_PATH shouldn't contain the current directory when
*** building glibc. Please change the environment variable
*** and run configure again.
make[3]: *** [Makefile:30: /opt/p2/openwrt/build_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/glibc-2.22-b995d95-headers/.configured] Error 1
make[3]: Leaving directory '/opt/p2/openwrt/toolchain/glibc/headers'

解決:
系統中安裝有makeinfo 6.7 真實指向的是texi2any  /usr/bin/makeinfo -> texi2any
安裝舊版的makeinfo4 發現無效
只能修改build_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/glibc-2.22-b995d95/configure
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $MAKEINFO" >&5
$as_echo_n "checking version of $MAKEINFO... " >&6; }
  ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
  test_info=`$MAKEINFO --version`
 $as_echo "$test_info";
  case $ac_prog_version in
    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
中的
    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
    改成
    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=no;;


8
問題:
checking LD_LIBRARY_PATH variable... contains current directory
configure: error:
*** LD_LIBRARY_PATH shouldn t contain the current directory when
*** building glibc. Please change the environment variable
*** and run configure again.

解決:
echo $LD_LIBRARY_PATH 查看當前LD_LIBRARY_PATH變量
:/usr/lib64:/usr/local/lib:/usr/local/lib64:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/usr/lib64:/usr/local/lib:/usr/local/lib64:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
第一個字符是多餘的,可以把它刪除,或者暴力點直接把變量清空
export LD_LIBRARY_PATH=''

9
問題
./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
*** Your dtc is too old, please upgrade to dtc 1.4 or newer
make[4]: *** [Makefile:1375: checkdtc] Error 1
make[4]: Leaving directory '/opt/p2/uboot'

解決:
系統中安裝dtc這個軟件

9
問題
make[8]: Entering directory '/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/gio'
  CC       libgio_2_0_la-gdbusauth.lo
gdbusauth.c: In function '_g_dbus_auth_run_server':
gdbusauth.c:1304:11: error: '%s' directive argument is null [-Werror=format-overflow=]
 1304 |           debug_print ("SERVER: WaitingForBegin, read '%s'", line);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[8]: *** [Makefile:3531: libgio_2_0_la-gdbusauth.lo] Error 1
make[8]: Leaving directory '/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/gio'

解決:
修改build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/giogdbusauth.c
          debug_print ("SERVER: WaitingForBegin, read '%s'", line);
          if (line == NULL)
            goto out;

          if (line == NULL)
            goto out;
          debug_print ("SERVER: WaitingForBegin, read '%s'", line);


10
問題:
gdbusmessage.c: In function 'g_dbus_message_to_blob':
gdbusmessage.c:2698:30: error: '%s' directive argument is null [-Werror=format-overflow=]
 2698 |       tupled_signature_str = g_strdup_printf ("(%s)", signature_str);

解決:
修改gdbusmessage.c 2698行
      tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
改爲
      if (signature_str)
        tupled_signature_str = g_strdup_printf ("(%s)", signature_str);

11
問題:
make[8]: Entering directory '/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/gio/tests'
  GEN      gdbus-test-codegen-generated.h
Traceback (most recent call last):
  File "../../gio/gdbus-2.0/codegen/gdbus-codegen", line 37, in <module>
    from codegen import codegen_main
  File "/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/gio/gdbus-2.0/codegen/codegen_main.py", line 28, in <module>
    from . import parser
  File "/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/glib-2.50.3/gio/gdbus-2.0/codegen/parser.py", line 23, in <module>
    import xml.parsers.expat
ImportError: No module named xml.parsers.expat
make[8]: *** [Makefile:4643: gdbus-test-codegen-generated.h] Error 1

解決:
系統中python安裝defusedxml模塊, 比如suse系統,在YaST2中搜索並安裝python2-defusedxml

13
問題
make[4]: Entering directory '/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13'
running build
running build_ext
building dbm using ndbm
INFO: Can't locate Tcl/Tk libs and/or headers
building '_curses' extension
gcc -pthread -fPIC -fno-strict-aliasing -O2 -I/opt/p2/openwrt/staging_dir/host/include -I/opt/p2/openwrt/staging_dir/host/usr/include -I/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/opt/p2/openwrt/staging_dir/host/include -I/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/include -I/usr/local/include -I/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Include -I/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13 -c /opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Modules/_cursesmodule.c -o build/temp.linux-x86_64-2.7/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Modules/_cursesmodule.o
/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Modules/_cursesmodule.c: In function 'PyCursesWindow_EchoChar':
/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Modules/_cursesmodule.c:809:18: error: dereferencing pointer to incomplete type 'WINDOW' {aka 'struct _win_st'}
  809 |     if (self->win->_flags & _ISPAD)
      |                  ^~
/opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/host/Python-2.7.13/Modules/_cursesmodule.c: In function 'PyCurses_setupterm':


*** WARNING: renaming "_ctypes" since importing it failed: libffi.so.6: cannot open shared object file: No such file or directory
Python build finished, but the necessary bits to build these modules were not found:
_sqlite3           _tkinter           bsddb185
dl                 imageop            nis

解決:
安裝tcl-devel, tk-devel, sqlite3-devel, libffi-devel,  注意必須要有libffi.so.6這個文件,實在沒有且有libffi.so.7的則可以ln -s libffi.so.7 libffi.so.6來做臨時解決。
如果還是不行,則試下安裝readline-devel,bzip2-devel,openssl-devel,gdbm-devel,libdbi-devel,ncurses-libs,zlib-devel, libnsl-devel

14
問題:
checking for refresh in -lncurses6... no
checking for refresh in -lncurses... no
checking for refresh in -lncurses6... (cached) no
checking for refresh in -lncurses... (cached) no
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
configure: error: missing libraries:  libncurses
make[3]: *** [Makefile:57: /opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/htop-2.0.2/.configured_yyyyyyyy] Error 

解決:
查看build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/htop-2.0.2/config.log
configure:13075: checking for refresh in -lncurses
configure:13100: arm-openwrt-linux-gnueabi-gcc -o conftest -Os -pipe -march=armv7-a -mtune=cortex-a7 -mfpu=neon -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -iremap /opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/htop-2.0.2:htop-2.0.2 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/include -I/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/include -I/opt/p2/openwrt/staging_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/usr/include -I/opt/p2/openwrt/staging_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/include  -L/usr/lib64/ncurses5 -Wl,-O2 -Wl,-Bsymbolic-functions -Wl,--as-needed -lncurses -ltinfo -L/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/lib -L/opt/p2/openwrt/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/lib -L/opt/p2/openwrt/staging_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/usr/lib -L/opt/p2/openwrt/staging_dir/toolchain-arm_cortex-a7+neon_gcc-5.3.0_glibc-2.22_eabi/lib -znow -zrelro  conftest.c -lncurses  -lm  >&5
/lib64/libncurses.so.5: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
configure:13100: $? = 1
關鍵是這句 -L/usr/lib64/ncurse5, 加上/lib64/libncurses.so.5: file not recognized: File format not recognized, 可見是鏈接目錄有問題,交叉編譯時卻鏈接上pc中的庫,無法識別,出錯。
系統中安裝了ncurses-devel  ncurses5-devel, 這裏刪除掉ncurses5-devel,問題解決。


15
問題:
+ mkdosfs /opt/p2/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/linux-leo_gx8009b-ssd-lc-v1/cfg.img -C 1024
./gen_leo_sdcard_img.sh: line 40: mkdosfs: command not found

解決:
系統安裝dosfstools, 如果是suse系統,又安裝有dosfstools, 則是路徑有問題(/usr/sbin/mkdosfs), 在/usr/bin/下創建軟鏈接sudo ln -s /usr/sbin/mkdosfs /usr/bin/mkdosfs

作者:帥得不敢出門
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章