简体   繁体   English

在C ++项目(Mac OS X,g ++,Eclipse)中静态链接MySQL

[英]Statically link MySQL in C++ Project (Mac OS X, g++, Eclipse)

I'm getting an error while trying to include libmysqlclient in a project. 尝试在项目中包含libmysqlclient时出现错误。 I'm using Mac OS X, Eclipse CDT, g++. 我正在使用Mac OS X,Eclipse CDT,g ++。

The error I'm getting is ld: library not found for -l/usr/local/mysql-5.6.15-osx10.7-x86_64/lib/libmysqlclient.a , even though I included this file by navigating to it with the finder. 我得到的错误是ld: library not found for -l/usr/local/mysql-5.6.15-osx10.7-x86_64/lib/libmysqlclient.a ,即使我通过使用发现者。

Can anyone help? 有人可以帮忙吗?

这是图书馆,包括

这是库路径,也包括在内

这是包含目录

If the -l linker flag is used, the correct value is -lmysqlclient , which would find either libmysqliclient.a or libmysqlclient.dylib on the library search path. 如果使用-l链接器标志,则正确的值为-lmysqlclient ,它将在库搜索路径上找到libmysqliclient.alibmysqlclient.dylib

To solve your problem, do one of the following: 要解决您的问题,请执行以下任一操作:

  1. Convince your IDE not to prepend -l to the full pathname. 说服您的IDE不要在全路径名前加上-l

  2. In your IDE settings, add /usr/local/mysql-5.6.15-osx10.7-x86_64/lib to the library search path (that's already done, as seen on the screen shots), and specify mysqlcient in the Libraries section, so -lmysqlclient would be passed to the linker. 在您的IDE设置中,将/usr/local/mysql-5.6.15-osx10.7-x86_64/lib添加到库搜索路径(如屏幕截图所示,已经完成),并在“ 库”部分中指定mysqlcient ,因此-lmysqlclient将被传递给链接器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM