我正在用MySQL Cpp Conn 6.1用C ++编写代码,以连接到数据库并写入数据供以后使用。尝试使用driver = get_driver_instance()初始化驱动程序时;它返回一条错误消息:

Creating executable: out/gcc-debug//DB8.exe
out/gcc-debug//defaultSensor.o: In function `Z10dbWriteWiniiiii':
C:\Users\LuisH.Forchesatto\Dropbox\ProjetosOmnet++\DB8/dbWriteWin.h:35: undefined reference to `_imp___ZN3sql5mysql19get_driver_instanceEv'
collect2.exe: error: ld returned 1 exit status
Makefile:85: recipe for target 'out/gcc-debug//DB8.exe' failed
make: *** [out/gcc-debug//DB8.exe] Error 1


我试图将mysqlcppconn添加到链接选项(-lmysqlcppconn),但它返回以下错误消息:

Creating executable: out/gcc-debug//DB8.exe
C:\Users\LuisH.Forchesatto\Downloads\omnetpp-4.6\tools\win32\mingw32\bin/ld.exe: cannot find -lmysqlcppconn
collect2.exe: error: ld returned 1 exit status
Makefile:85: recipe for target 'out/gcc-debug//DB8.exe' failed
make: *** [out/gcc-debug//DB8.exe] Error 1



如果我包括mysqlcppconn.dll或.lib的完整路径以及包括它们的路径和符号目录,则将出现此错误。


尝试连接数据库时,未初始化的驱动程序变量可能会导致崩溃,因此它需要工作。

路径和符号包含mysqlcppconn标头和boost库标头的include。该应用程序的完整代码在下面的链接中。

https://dl.dropboxusercontent.com/u/85576999/dbWriteWin.h

最佳答案

2种可能的错误原因,
IF-您指的是未声明的函数或变量
II-编译时未包含适当的库

关于c++ - 未定义对get_mysql_instance的引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32792117/

10-11 21:08