0

我经常使用 mysql c api,因此将它们链接到我的 c 项目中,在 xcode 下开发。

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

但是,如果我尝试构建 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

要在 xcode 下包含 mysqllib,必须将以下行添加到 build set-ip “other linker flags”:

-lmysqlclient -lm -lz

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

使用普通的命令行程序,它工作正常,我多年来一直在使用它。

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

提前致谢

索利克

4

2 回答 2

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 (\)
于 2013-09-26T04:41:42.700 回答
0

解决了我的问题:在对我有用的主程序中包含了 mysql lib。

于 2013-08-23T04:57:03.183 回答