2015-09-25 98 views
0

我正在用C++編寫代碼,使用MySQL Cpp Conn 6.1連接到數據庫並寫入數據供以後使用。嘗試使用driver = get_driver_instance()初始化驅動程序時;它返回一條錯誤消息:未定義的引用get_mysql_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庫頭文件。應用程序的完整代碼位於下面的鏈接中。

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

回答

0

2個可能的錯誤原因, 我 - 你指的undeclered函數或變量 II - 你地圖無法包括編譯時間

+0

請,你能不能詳細闡述了正確的庫?什麼庫可能會丟失?需要聲明哪些功能?我已經嘗試了很多,似乎沒有任何工作。 –

+0

更新:我讀了我需要-lmysqlcppconn和-lmysqlcppconn-static以獲取驅動程序實例。但是,當我嘗試添加這些時,我收到以下錯誤消息: https://dl.dropboxusercontent.com/u/85576999/error.txt (是的,這是一個很長的錯誤消息) –