樹莓派4 ubuntu20.04安裝PyInstaller

1、正常情況下,我們是通過pip3來安裝PyInstaller,但是在樹莓派的ubuntu20.04上安裝時,會報錯如下:

In function ‘strncpy’,
      inlined from ‘splitName’ at ../../src/pyi_launch.c:83:5,
      inlined from ‘_extract_dependency’ at ../../src/pyi_launch.c:215:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4097 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_utils.c:60:
  In function ‘strncpy’,
      inlined from ‘pyi_open_target’ at ../../src/pyi_utils.c:561:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncpy’,
      inlined from ‘pyi_open_target’ at ../../src/pyi_utils.c:562:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_pythonlib.c:39:
  In function ‘strncpy’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:487:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncat’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:491:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin___strncat_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_pythonlib.c: In function ‘pyi_pylib_start_python’:
  ../../src/pyi_pythonlib.c:491:9: note: length computed here
    491 |         strncat(pypath, status->mainpath, strlen(status->mainpath));
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_pythonlib.c:39:
  In function ‘strncpy’,
      inlined from ‘pyi_pylib_start_python’ at ../../src/pyi_pythonlib.c:483:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncpy’,
      inlined from ‘pyi_path_join’ at ../../src/pyi_path.c:146:5:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_path.c: In function ‘pyi_path_join’:
  ../../src/pyi_path.c:146:5: note: length computed here
    146 |     strncpy(result, path1, strlen(path1));
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncat’,
      inlined from ‘pyi_path_join’ at ../../src/pyi_path.c:159:9:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
    136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../src/pyi_path.c: In function ‘pyi_path_join’:
  ../../src/pyi_path.c:155:11: note: length computed here
    155 |     len = strlen(path2);
        |           ^~~~~~~~~~~~~
  In file included from /usr/include/string.h:495,
                   from ../../src/pyi_path.c:38:
  In function ‘strncpy’,
      inlined from ‘pyi_search_path’ at ../../src/pyi_path.c:256:13:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output may be truncated copying 4096 bytes from a string of length 4096 [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function ‘strncpy’,
      inlined from ‘pyi_path_executable’ at ../../src/pyi_path.c:331:13:
  /usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
    106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  
  Waf: Leaving directory `/tmp/pip-install-1jgb0leb/pyinstaller/bootloader/build/debug'
  Build failed
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)
   -> task in 'run_d' failed with exit status 1 (run with -v to display more information)

2、通過錯誤提示,我們可以分析出來,這裏報的錯誤爲Werror,即在用gcc編譯時,將警告信息當作錯誤來處理,並不是真的時運行不下去,所以,我們要做的就是修改makefile,讓使用gcc編譯的時候,不進行Werror處理;

3、我們從pip官網下載pyinstaller源碼

 https://pypi.org/project/PyInstaller/

4、將源碼解壓,打開,嘗試直接運行python3 setup.py install ,依舊會報上面的錯誤,現在重點來了,修改make文件,這裏這個make文件也找到了好半天才找到

//進入pyinstaller源碼下面的bootloader文件夾

cd bootloader

//編輯make文件,這裏是wscript

vim wscript

//通過/Werror查找,我們可以找到在第461,gcc的參數裏面有Werror這個參數,直接刪除這一行參數就行,注意只刪除‘-Werror’這一句

//保存退出,返回pyinstaller的根目錄

//安裝就可以了
python3 setup.py install

OK,至此pyinstaller就安裝完成了,可以使用他來發布你的QT程序了 

 

 

 

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