[英]Undefined reference to get_mysql_instance
I'm writing a code in C++ with MySQL Cpp Conn 6.1 to connect to a database and write data for later use. 我正在用MySQL Cpp Conn 6.1用C ++编写代码,以连接到数据库并写入数据供以后使用。 When trying to initialize the driver with driver = get_driver_instance();
尝试使用driver = get_driver_instance()初始化驱动程序时; it returns an error message:
它返回一条错误消息:
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
I tried to add mysqlcppconn to the link option (-lmysqlcppconn) but it returns the following error message: 我试图将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
The non initialized driver variable may be causing crashes when trying to connect to the database so it needs to work. 尝试连接到数据库时,未初始化的驱动程序变量可能会导致崩溃,因此它需要工作。
The paths and symbols contains the includes for mysqlcppconn headers and boost library headers. 路径和符号包含mysqlcppconn标头和boost库标头的include。 The full code to the application is in the link below.
该应用程序的完整代码在下面的链接中。
https://dl.dropboxusercontent.com/u/85576999/dbWriteWin.h https://dl.dropboxusercontent.com/u/85576999/dbWriteWin.h
2种可能的错误原因,I-您引用的函数不受约束或变量II-您在编译时未包含适当的库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.