MySQL的Macports编译++失败
在运行“sudo port install mysqlxx +universal”之前,我安装了mysql5的通用版本。
... 检查是否需要 -lm 来使用 C 数学函数...不
检查是否需要 -lsocket...不
检查是否需要 -lnsl...不
检查 MySQL 库目录.../opt/local/lib/ mysql5/mysql
检查 MySQL 包含目录... /opt/local/include/mysql5/mysql
检查我们是否可以直接链接到 MySQL C API 库... 不
检查 zlib.h 可用性... 是
检查 zlib.h 存在...是
检查 zlib.h...是
检查 -lz 中的 gzread...是
检查添加 -lz 是否会让 MySQL C API 链接成功...否
配置:错误:无法链接到 MySQL 客户端库!
Before running "sudo port install mysqlxx +universal", I installed the universal variant of mysql5.
...
checking whether -lm is needed to use C math functions... no
checking whether -lsocket is needed... no
checking whether -lnsl is needed... no
checking for MySQL library directory... /opt/local/lib/mysql5/mysql
checking for MySQL include directory... /opt/local/include/mysql5/mysql
checking if we can link to MySQL C API library directly... no
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for gzread in -lz... yes
checking whether adding -lz will let MySQL C API link succeed... no
configure: error: Unable to link to MySQL client library!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑这里发生的事情是您正在运行 Snow Leopard。在以前版本的 OS X 中,默认的 C++ 编译器默认构建 32 位可执行文件,但在 Snow Leopard 中更改为 64 位。如果 MySQL C API 库不是构建为支持 64 位和 32 位可执行文件的通用库,则可能会导致该库出现链接问题。
有很多方法可以解决这个问题,但我所知道的大多数方法要么不适用于 MacPorts,要么我不知道如何让它们工作。我已经在 Mac OS X 的 MySQL++ 自述文件中添加了有关此内容的部分,您可以在线阅读该部分,此处。
也许您可以弄清楚如何使这些解决方案适应 MacPorts 构建系统。像这样的东西可能会起作用:
这取决于那些环境变量是否能够通过 sudo 和 port 障碍。你可能需要变得更狡猾。例如:
正如我上面评论的,从源 tarball 构建可能是最简单的。
I suspect what's going on here is that you're running Snow Leopard. In previous versions of OS X, the default C++ compiler built 32-bit executables by default, but this changed to 64-bit in Snow Leopard. This can cause link problems with the MySQL C API library if it's not built as a Universal library supporting both 64- and 32-bit executables.
There are a bunch of ways around this problem, but most of the ones I know about either won't work with MacPorts or I don't know how to make them work. I've added a section on this to the MySQL++ README for Mac OS X, which you can read online, here.
Perhaps you can figure out how to adapt these solutions to the MacPorts build system. Something like this might work:
That depends on those environment variables making it through the
sudo
andport
barriers. You might have to get trickier. For instance:As I commented above, it might be simplest to just build from the source tarball.