gpt4 book ai didi

mysql - Eclipse中使用C程序连接MYSQL

转载 作者:行者123 更新时间:2023-11-30 17:57:11 24 4
gpt4 key购买 nike

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

但我收到错误

**** 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 ****

请帮我解决这个问题提前致谢

最佳答案

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

../connection.c:39: warning: implicit declaration of function `exit'

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

../connection.c:46: warning: control reaches end of non-void function

您没有在 main() 末尾返回值,添加return 0;如果程序成功。

第二部分是链接器警告:

/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

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

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

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

关于mysql - Eclipse中使用C程序连接MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12974254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com