rk3568 linux sdk recovery buildroot “host-python-2.7.16“ compile failed

when compile rk3568 linux sdk recovery, it shows that buildroot package "host-python-2.7.16" build failed, open "rk3568_linux_sdk/br.log" or "rk3568_linux_sdk/buildroot/br.log", scroll to the end, we can find the logs:

2024-08-31T09:20:31 /usr/bin/gcc -shared -L/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/host/lib -Wl,-rpath,/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/host/lib -Wl,--enable-new-dtags build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/_ctypes.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/callbacks.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/callproc.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/stgdict.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/cfield.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/prep_cif.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/closures.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/x86/ffi64.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/x86/unix64.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/x86/ffi.o build/temp.linux-x86_64-2.7/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/Modules/_ctypes/libffi/src/x86/sysv.o -L/home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/host/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L. -lpython2.7 -o build/lib.linux-x86_64-2.7/_ctypes.so
2024-08-31T09:20:31 /usr/bin/ld: /usr/local/lib/libpython2.7.a(posixmodule.o): in function `posix_tempnam':
2024-08-31T09:20:31 /home/oushaojun/Desktop/temp/Python-2.7.18/./Modules/posixmodule.c:7595:(.text+0xbde): warning: the use of `tempnam' is dangerous, better use `mkstemp'
2024-08-31T09:20:31 /usr/bin/ld: /usr/local/lib/libpython2.7.a(posixmodule.o): in function `posix_tmpnam':
2024-08-31T09:20:31 /home/oushaojun/Desktop/temp/Python-2.7.18/./Modules/posixmodule.c:7648:(.text+0xac6): warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
2024-08-31T09:20:31 /usr/bin/ld: /usr/local/lib/libpython2.7.a(signalmodule.o): warning: relocation against `PyExc_KeyboardInterrupt' in read-only section `.text'
2024-08-31T09:20:31 /usr/bin/ld: /usr/local/lib/libpython2.7.a(floatobject.o): relocation R_X86_64_PC32 against symbol `PyExc_TypeError' can not be used when making a shared object; recompile with -fPIC
2024-08-31T09:20:31 /usr/bin/ld: final link failed: bad value
2024-08-31T09:20:31 collect2: error: ld returned 1 exit status
2024-08-31T09:20:31 
2024-08-31T09:20:31 Python build finished, but the necessary bits to build these modules were not found:
2024-08-31T09:20:31 _bsddb             _hashlib           _sqlite3
2024-08-31T09:20:31 _tkinter           bsddb185           bz2
2024-08-31T09:20:31 dbm                dl                 gdbm
2024-08-31T09:20:31 imageop            nis                readline
2024-08-31T09:20:31 sunaudiodev
2024-08-31T09:20:31 To find the necessary bits, look in setup.py in detect_modules() for the module's name.
2024-08-31T09:20:31 
2024-08-31T09:20:31 
2024-08-31T09:20:31 Failed to build these modules:
2024-08-31T09:20:31 _bisect            _codecs_iso2022    _collections
2024-08-31T09:20:31 _csv               _ctypes            _ctypes_test
2024-08-31T09:20:31 _elementtree       _functools         _heapq
2024-08-31T09:20:31 _hotshot           _io                _json
2024-08-31T09:20:31 _locale            _lsprof            _md5
2024-08-31T09:20:31 _multibytecodec    _multiprocessing   _random
2024-08-31T09:20:31 _sha               _sha256            _sha512
2024-08-31T09:20:31 _socket            _ssl               _struct
2024-08-31T09:20:31 _testcapi          array              audioop
2024-08-31T09:20:31 binascii           cmath              cPickle
2024-08-31T09:20:31 crypt              cStringIO          datetime
2024-08-31T09:20:31 fcntl              future_builtins    grp
2024-08-31T09:20:31 itertools          linuxaudiodev      math
2024-08-31T09:20:31 mmap               operator           parser
2024-08-31T09:20:31 pyexpat            resource           select
2024-08-31T09:20:31 spwd               strop              syslog
2024-08-31T09:20:31 termios            time               unicodedata
2024-08-31T09:20:31 zlib
2024-08-31T09:20:31 
2024-08-31T09:20:31 make[2]: *** [Makefile:544: sharedmods] Error 1
2024-08-31T09:20:31 make[1]: *** [package/pkg-generic.mk:231: /home/oushaojun/rk3568_linux_sdk/buildroot/output/rockchip_rk356x_recovery/build/host-python-2.7.16/.stamp_built] Error 2
2024-08-31T09:20:31 make: *** [Makefile:83: _all] Error 2

focus on this line " /usr/bin/ld: /usr/local/lib/libpython2.7.a(floatobject.o): relocation R_X86_64_PC32 against symbol `PyExc_TypeError' can not be used when making a shared object; recompile with -fPIC", the file “/usr/local/lib/libpython2.7.a” is python2's install file, which is created by python2.7.18 source code compilation, it says  “libpython2.7.a” compiled without "-fPIC", so we need to rebuild python2.7.18 source code in ubuntu and reinstall.

steps:

1 download python2.7.18, refer to: https://blog.csdn.net/lsqtzj/article/details/114298091

2 after unpacking source code, we need to configure python2.7.18 with command below, "CFLAGS=-fPIC" is critical, it applys to every c file compilation:

./configure --enable-optimizations CFLAGS=-fPIC

3 build and install python2.7.18. when building new python2.7.18, you may need to uninstall former installed old python2 and swtich to python3, refer to this link to uninstall python2 :software installation - uninstall Python installed by compiling source? - Unix & Linux Stack Exchange

4 enter "rk3568_linux_sdk", type command "./build.sh recovery", now host-python-2.7.16 in recovery buildroot would be ok.

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值