2013-08-22 62 views
0

我经常使用mysql c api,因此将它们链接到我的c项目中,开发了unter xcode。在静态库中链接Mysqllib(MAC OS X.8.4,Xcode 4.6.3)

昨天我试图建立一个静态库来封装一些数据库函数。

但是,如果我尝试建立的lib有发生一些奇怪的错误:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lm 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lm is not an object file (not allowed in a library) 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lz 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lz is not an object file (not allowed in a library) 
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool failed with exit code 1 

到包括mysqllib下的Xcode,需要将下面的行添加到生成设置IP“其他连接标志” :

-lmysqlclient -lm -lz 

据我所知,xcode无法在静态库中使用此链接器标志。

使用正常的命令行程序,它工作正常,我使用它多年。

有没有人有暗示我如何处理这个问题?

在此先感谢

solick

回答

0

解决我的问题:包括在主程序这个工作对我来说是MySQL的库。

1

我在使用较新的iOS7版本替换旧外部库时,在XCode 5上出现类似错误。

ie: 
...can't locate file for: -l 
...is not an object file (not allowed in a library) 

我发现Xcode5正确逃逸双引号,同时插入库搜索路径project.pbxproj

ie: 

incorrect behaviour ---> "\\\"/path/library/\\\"", (note: 3 slashes) 
correct behaviour ----> "\"/path/library/\"",  (note: 1 slash) 

解决方案

开放project.pbxproj,做一个搜索,并迅速取代固定我的问题。

ie: search(\\\) replace with (\)