mac xcode5.1安装Mysql-python编译异常解决

mac xcode5.1安装Mysql-python编译错误解决

前几天才入的macbook air,在 app store 安装的xcode和command_line_tools都是最新版本,结果我被坑了,编译工具太新了,不兼容,出现错误。

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]


我在mysql-python.sourceforge.net下载MySQL-python-1.2.4b4.tar.gz 

shell cmd :

   tar -cjf MySQL-python-1.2.4b4.tar.gz 

   cd MySQL-python-1.2.4b4 

   python setup.py build

然后出现下面都错误代码

build/lib.macosx-10.9-intel-2.7/MySQLdb running build_ext building '_mysql' extension
cc -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,'beta',4) -D__version__=1.2.4b4 -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.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

说一下问题分析过程,我开始分析  setup.py里面的代码,想找出编译选项-mno-fused-madd,然后将它删除,可是找了半天没找到,

发现python调用的是setuptools模块,我就去找这个模块的代码,最后发现是一个egg包,没办法去看它的源码。


最后没办法了,我想了一下应该是我的编译工具太新了的原因。

最后成功解决办法

我在网上找到xcode5.0.2和老一点版本的command_line_tools的dmg包

卸载xcode5.1然后安装这两个包,最后问题解决了!!!