我正在使用Mysql
连接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 ****
请帮我解决这个问题 提前谢谢
答案 0 :(得分:0)
在第一部分中,您会对可能出现的问题发出一些警告:
../ connection.c:39:警告:隐式声明函数`exit'
这意味着未声明函数exit()
,您的来源需要#include <stdlib.h>
../ connection.c:46:warning:control到达非空函数的结尾
您不会在main()
的末尾返回值,如果程序成功,则添加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并查看一些图书链接。