在Windows 8上使用Code::Blocks 13.12
和MingW 4.8.1
即可。我嘗試以動態和靜態方式鏈接MySQL C++ Connector 1.1.4
。 當編譯它不會給出錯誤,但是當啓動exe時它會停止工作。EXE在編譯後停止工作。 (Mysql C++連接器)
我嘗試下面的代碼:
#include <iostream>
#include "mysql_connection.h"
#include "cppconn/driver.h"
using namespace sql;
int main() {
Driver *driver;
Connection * con;
std::cout << "1\n";
driver = get_driver_instance();
std::cout << "2\n";
con = driver->connect("TCP://127.0.0.1:3306", "test", "test");
std::cout << "3\n";
return 0;
}
大廈不給錯誤:
-------------- Build: Debug in mysql_connect (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -fexceptions -g -DCPPCONN_PUBLIC_FUNC= -ID:\Development\Libraries\boost_1_56_0 -c D:\Development\Projects\codeblocks\mysql_connect\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LD:\Development\Libraries\boost_1_56_0 -o bin\Debug\mysql_connect.exe obj\Debug\main.o "C:\Program Files (x86)\MySQL\Connector.C++ 1.1\lib\opt\mysqlcppconn.lib"
Output file is bin\Debug\mysql_connect.exe with size 66.01 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
這裏是gdb
給出的日誌:
Starting debugger: D:\Development\Compiler\MingW\bin\gdb.exe -nx -fullname -quiet -args D:/Development/Projects/codeblocks/mysql_connect/bin/Debug/mysql_connect.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 4236
In RaiseException() (C:\Windows\SysWOW64\KernelBase.dll)
#13 0x00401468 in _fu1___ZSt4cout() at D:\Development\Projects\codeblocks\mysql_connect\main.cpp:13
D:\Development\Projects\codeblocks\mysql_connect\main.cpp:13:252:beg:0x401468
At D:\Development\Projects\codeblocks\mysql_connect\main.cpp:13
Continuing...
[Inferior 1 (process 4236) exited with code 0377]
Debugger finished with status 0
1
和2
是在控制檯上成功打印,但是3
不是。 Process returned 255 (0xFF)
。
程序無法在這一行:
con = driver->connect("TCP://127.0.0.1:3306", "test", "test");
莫非
任何人的幫助,以得到它的工作?
如果我評論它的連接線,它的工作原理。打印1,2,3。 – 2014-10-11 11:58:48
您的防火牆允許傳出連接這個EXE? – GSerg 2014-10-11 15:25:01
是的!由「Code :: Blocks」引起的問題。 – 2014-10-11 15:57:07