简体   繁体   English

未定义对get_mysql_instance的引用

[英]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
  • this error applies if I include the full path to mysqlcppconn.dll or .lib as well as including their directories to paths and symbols. 如果我包括mysqlcppconn.dll或.lib的完整路径以及包括它们的路径和符号目录,则将出现此错误。

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.

相关问题 MySQL C++ 连接器:对“get_driver_instance”的未定义引用 - MySQL C++ Connector: undefined reference to `get_driver_instance' 对'get_driver_instance'的未定义引用 - undefined reference to 'get_driver_instance' C ++ / mysql连接器 - 对get_driver_instance的未定义引用 - 已经尝试过简单的东西 - C++ / mysql Connector - undefined reference to get_driver_instance - already tried the easy stuff 具有静态实例的未定义​​引用 - undefined reference with a static instance 对Singleton :: instance的未定义引用 - Undefined reference to Singleton::instance 对mysql_init的未定义引用 - Undefined reference to `mysql_init' C ++:对Singleton类中实例的未定义​​引用 - C++: Undefined reference to instance in Singleton class 库路径绝对正确,可以创建该库的实例,但是在调用任何函数时都会得到“未定义的引用” - Library path is definitely correct and can create an instance of said library, but get “Undefined reference” when calling any function QT MYSQL 驱动器构建,未定义对 `mysql_get_client_version@0' 的引用 - QT MYSQL drive build, undefined reference to `mysql_get_client_version@0' 在mysql连接器中未定义对mysqlx函数的引用 - Undefined reference to mysqlx function in mysql connector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM