0

我正在连接Mysqlusing c program in eclipse,我正在使用CYGWIN编译器来编译程序。我已经安装mysql c connector并将包含文件添加到编译器和链接器

但我收到错误

**** Build of configuration Debug for project DbConnectionC ****

make all 
Building file: ../connection.c
Invoking: Cygwin C Compiler
gcc -I"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -include"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\mysql.h" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"connection.d" -MT"connection.d" -o "connection.o" "../connection.c"
cygwin warning:
  MS-DOS style path detected: D:\java\workspace\DbConnectionC\Debug
  Preferred POSIX equivalent is: /cygdrive/d/java/workspace/DbConnectionC/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
../connection.c: In function `main':
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
Finished building: ../connection.c

Building target: DbConnectionC.exe
Invoking: Cygwin C Linker
gcc -L"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" -o "DbConnectionC.exe"  ./connection.o   -llibmysql.lib -lmysqlclient.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -llibmysql.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient.lib
collect2: ld returned 1 exit status
make: *** [DbConnectionC.exe] Error 1
makefile:29: recipe for target `DbConnectionC.exe' failed

**** Build Finished ****

请提前帮助我

4

1 回答 1

0

在第一部分中,您有一些关于可能出现的问题的警告:

../connection.c:39:警告:函数“退出”的隐式声明

这意味着exit()未声明函数,您的源代码需要一个#include <stdlib.h>

../connection.c:46:警告:控制到达非无效函数的结尾

末尾不返回值,如果程序成功main(),则添加 a 。return 0;

第二部分是链接器警告:

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:找不到-llibmysql.lib
/usr/lib/ gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:找不到-lmysqlclient.lib

这意味着链接器需要库的路径,或者库不存在或库名称拼写错误。

一种可能的解决方案是使用-lmysql -lmysqlclient而不是-llibmysql.lib -lmysqlclient.lib,但我对 Windows 不是很熟悉。

话虽如此,我强烈建议您查看https://stackoverflow.com/tags/c/info并查看一些书籍链接。

于 2012-10-19T12:36:52.523 回答