【问题标题】:Cross gdb can't find python跨gdb找不到python
【发布时间】:2016-07-03 21:19:35
【问题描述】:

我使用 MSYS2/MINGW64 在 Windows 上构建了一个支持 python 的交叉 gdb。我已经在MINGW64中安装了python,即我在C:\msys64\mingw64\bin中有python2.7.exe,这个地址在我的路径中。

运行 gdb 时出现以下错误

 Could not find platform independent libraries <prefix>
 Could not find platform dependent libraries <exec_prefix>
 Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
 ImportError: No module named site`

我还在libpython2.7.dll.a 的位置添加了C:\msys64\mingw64\lib,但我仍然遇到同样的错误。

我也尝试在windows上安装python并设置了所有路径,但还是同样的错误。

如何让 gdb 找到 python?

【问题讨论】:

    标签: python gdb mingw cross-compiling msys2


    【解决方案1】:

    你必须设置环境变量:

    PYTHONPATH=C:\msys64\mingw64\lib\python2.7;C:\msys64\mingw64\lib\python2.7\lib-dynload;

    PYTHONHOME 变量引用 python 解释器:

    PYTHONHOME=C:\msys64\mingw64\bin\pyhon.exe
    

    我在 msys2 下构建了自己的 gdb,设置正确的环境变量后它可以工作:

    Microsoft Windows [Version 10.0.16299.19]
    (c) 2017 Microsoft Corporation. All rights reserved.
    
    C:\Users\tiit>echo %PYTHONHOME%
    C:\msys64\mingw64\bin\pyhon.exe
    
    C:\Users\tiit>echo %PYTHONPATH%
    C:\msys64\mingw64\lib\python2.7;C:\msys64\mingw64\lib\python2.7\lib-dynload;
    
    C:\Users\tiit>C:\msys64\home\tiit\gdb-7.11-bin\bin\x86_64-linux-gnu-gdb.exe
    GNU gdb (GDB) 7.11.1.20160801-git
    Copyright (C) 2016 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later
    <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=x86_64-w64-mingw32 --target=x86_64-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    (gdb)
    

    我的配置命令行是:

    ./configure --target=x86_64-linux-gnu --prefix=/home/tiit/gdb-7.11-bin --with-python=/mingw64/bin/python.exe --enable-static=yes
    

    【讨论】:

      猜你喜欢
      • 2013-12-04
      • 2016-01-03
      • 2014-07-30
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 2016-03-27
      • 1970-01-01
      相关资源
      最近更新 更多