在Mac 10.7.5上安装Python-MySQL时,出现了错误消息“cc1: error: unrecognized command line option "-Wno-null-conversion"”。

9

这个错误损坏了我在Mac 10.7.5上的Python-MySQL安装。以下是步骤:

  1. The installed python is 2.7.1, mysql is 64 bit for 5.6.11.
  2. The being installed python-mysql is 1.2.4, also tried 1.2.3
  3. Configurations for the installation

    1) sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
    2) Edit the setup_posix.py and change the following mysql_config.path = "mysql_config" to mysql_config.path = "/usr/local/mysql/bin/mysql_config" 
    3) sudo python setup.py build
    
这是构建过程中的堆栈跟踪信息:
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.7-intel-2.7/MySQLdb
running build_ext
building '_mysql' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.7-intel-2.7/_mysql.o -Wno-null-conversion -Os -g -fno-strict-aliasing -arch x86_64
cc1: error: unrecognized command line option "-Wno-null-conversion"
error: command 'llvm-gcc-4.2' failed with exit status 1

欢迎您提出建议和想法。谢谢。

2个回答

26

尝试移除cflags -Wno-null-conversion -Wno-unused-private-field

/usr/local/mysql/bin/mysql_config.

喜欢:

cflags="-I$pkgincludedir  -Wall   -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!

5
移除它们后,安装成功。出现了一个新错误:“Python mysqldb: Library not loaded: libmysqlclient.18.dylib”,可以参考这个帖子解决:https://dev59.com/y2w15IYBdhLWcg3w0e8V。 - Joseph
这也解决了我的问题,我试图安装mysql2 gem。我查看了gems/mysql2-0.3.11/ext/mysql/mkmf.log并发现了相同的错误。删除-Wno-null-conversion和-Wno-unused-private-field使其正常工作,没有问题。现在我只希望知道它们是做什么的...另外,由于我使用homebrew安装mysql,我的mysql_config位于:/usr/local/Cellar/mysql/5.6.12/bin/mysql_config。 - JT.

0
哇,我花了几个小时试图在这里“pip install MySQL-python”。我已经重新安装了Xcode 4.6.3,单独安装了Xcode命令行工具(在Mac OS X 10.7.5上),并安装了Kenneth Reitz的东西(https://github.com/kennethreitz/osx-gcc-installer),但都没有成功...
最后修改了cflags选项终于帮助解决了问题!
谢谢!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接