【问题标题】:Error compiling a c++ with Python bindings using mingw and msys使用 mingw 和 msys 编译带有 Python 绑定的 c++ 时出错
【发布时间】:2012-05-26 17:23:06
【问题描述】:

我的环境:Windows 7 64 pro、mingw32(使用 2012-04-26.exe 安装程序安装)、msys 1.0、使用 python.org 的 Win64 安装程序安装的 Python 2.7.3

我正在尝试使用 mingw 和 msys 编译具有 python 绑定的 c++ 程序。当我从 msys shell 运行配置时,我得到了错误

Could not link test program to Python. 
Maybe the main Python library has been installed in some non-standard library path. 
If so, pass it to configure, via the LDFLAGS environment variable. 
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"

============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution.  The exact name of this package varies among them.
============================================================================

我已尝试使用以下各项运行配置:

./configure LDFLAGS="-L/c/Python27/libs"

./configure LDFLAGS="-L/c/Python27/Lib"

./configure LDFLAGS="-Lc:/Python27/libs"

./configure LDFLAGS="-Lc:/Python27/libs"

并且都给了我同样的最终错误。我已将整个 config.log 文件发布在 http://pastebin.com/fZVjTeub。有什么帮助吗?

【问题讨论】:

  • 你的python路径有效吗? c/Python27/Lib 看起来有点奇怪,不应该是 c:/Python27/Lib 还是你有一个符号链接将 c 指向你的 c: 驱动器?
  • 感谢@EdChum,我尝试了不同的变体,但似乎没有任何帮助。 msys shell 有 /c 符号链接(这是正确的术语吗?)到 c:/
  • 从它认为你的 python 所在的终端查看,并使用该路径,记住它是区分大小写的,所以尝试cd 到不同的文件夹,直到你找到 python 文件夹的位置。
  • 哪个python返回/c/Python27/./python.exe
  • python 库在哪里?您可以尝试设置指向 libs 文件夹的符号链接并将其传递给 ./configure 吗?

标签: c++ python mingw


【解决方案1】:

问题归根结底是我使用的是 32 位编译器并试图将其链接到 64 位 Python。

【讨论】:

    【解决方案2】:

    就我而言,我必须将LDFLAGS="-L/c/Python27/libs" 传递给./configure

    【讨论】:

    • 这没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
    • @Victor 为什么不提供答案?他就是这样解决问题的。
    • 答案不应该以在我的情况下开头。您应该提供带有一些文档的解决方案来支持它。
    猜你喜欢
    • 2011-11-07
    • 2010-12-11
    • 1970-01-01
    • 2011-07-12
    • 2014-11-02
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多