【问题标题】:Makefile Error after adding C mysql libs Eclipse CDT添加 C mysql 库 Eclipse CDT 后生成文件错误
【发布时间】:2012-11-22 14:32:55
【问题描述】:

我正在使用 Eclipse Juno CDT。

我在我的项目中添加了以下内容:

  • 包含路径设置的 mysql/includes 路径
  • libmysql.lib 和 zlib.lib 到库设置
  • 库路径设置的mysql库路径

现在,当我创建项目时,在运行应用程序时编译会引发错误。 这是构建:

10:08:56 **** Build of configuration Debug for project mysqlapp ****
make all 
Building file: ../src/mysqlapp.c
Invoking: Cygwin C Compiler
gcc -I"C:\Program Files\MySQL\MySQL Connector C 6.0.2\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/mysqlapp.d" -MT"src/mysqlapp.d" -o "src/mysqlapp.o" "../src/mysqlapp.c"
cygwin warning: 
MS-DOS style path detected: C:\Users\Yonaton\workspace\mysqlapp\Debug
Preferred POSIX equivalent is: /cygdrive/c/Users/Yonaton/workspace/mysqlapp/Debug
 CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../src/mysqlapp.c

Building target: mysqlapp.exe
Invoking: Cygwin C Linker
gcc -L"C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt" -o "mysqlapp.exe"  ./src/mysqlapp.o   
Finished building target: mysqlapp.exe

这是 eclipse 中的运行:

10:09:55 **** Incremental Build of configuration Debug for project mysqlapp ****
make all 
src/mysqlapp.d:1: *** multiple target patterns.  Stop.

10:09:56 Build Finished (took 225ms)

【问题讨论】:

  • 例如LIBS 应携带-lz -lmysql
  • 我认为您使用的是 Windows,gcc/cygwin 配置正确吗?
  • 是的。它配置了eclipse。
  • 错误信息添加到问题
  • 您可能希望粘贴 Eclipse 的控制台输出以进行构建。

标签: mysql c eclipse makefile eclipse-cdt


【解决方案1】:

Project->Properties->C/C++ General->Paths and Symbols->Libraries下不要添加库的文件名,也不要添加路径。

因此,如果您想链接到 /lib64/libz.so,只需添加 z

或者在Project->Properties->C/C++ Build->Settings->GCC Linker->Libraries下添加z

如果库不在标准路径下,请在 Project->Properties->C/C++ General->Paths and Symbols->Libraries Paths 下添加库的自定义搜索路径。


更新(指“多目标模式”)

make 不喜欢 DOS 路径。在.d 文件中,驱动器号后面的: 被解释为目标分隔符。

切换到 UNIX 路径(正如您已经被告知的那样...... ;-))。

(另见:"multiple target patterns" Makefile error

【讨论】:

  • 我在 Eclipse 中添加库。我不是自己构建makefile
  • 我指的是 Eclipse Juno。请参阅我更新的答案。 @jkushner
  • K 这似乎解决了它。现在我有另一个问题......当我运行应用程序时,它工作正常......但是,在 Eclipse 中,它会提示一个新错误 - 在 mysqlapp.d 中,它显示“多个目标模式”。它似乎包含了两次 mysql 库文件。
  • @jkushner:添加mysqlapp.d的内容,或许?
  • 如何在eclipse中切换到unix风格?我应该从cygwin运行eclipse吗?不是 elipse 应该处理所有这些,还是基于 cygwin 的问题?
【解决方案2】:

如果我没记错的话,你的库之前有“-l”(小 L)。

【讨论】:

  • 这个文件是由eclipse构建的。我不认为它的那个问题。我更新了我的问题。
猜你喜欢
  • 2011-12-22
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-16
  • 2011-05-27
  • 1970-01-01
  • 2012-03-09
相关资源
最近更新 更多