EXE在编译后停止工作.(MysqlC++连接器)
EXE stops working after compile. (Mysql C++ Connector)
Im在Windows 8上使用Code::Blocks 13.12
和MingW 4.8.1
。我尝试以动态和静态的方式连接MySQL C++ Connector 1.1.4
。编译时不会出现错误,但启动exe时会停止工作。
我尝试了以下代码:
#include <iostream>
#include "mysql_connection.h"
#include "cppconn/driver.h"
using namespace sql;
int main() {
Driver *driver;
Connection * con;
std::cout << "1n";
driver = get_driver_instance();
std::cout << "2n";
con = driver->connect("TCP://127.0.0.1:3306", "test", "test");
std::cout << "3n";
return 0;
}
建筑不会出错:
-------------- Build: Debug in mysql_connect (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -fexceptions -g -DCPPCONN_PUBLIC_FUNC= -ID:DevelopmentLibrariesboost_1_56_0 -c D:DevelopmentProjectscodeblocksmysql_connectmain.cpp -o objDebugmain.o
mingw32-g++.exe -LD:DevelopmentLibrariesboost_1_56_0 -o binDebugmysql_connect.exe objDebugmain.o "C:Program Files (x86)MySQLConnector.C++ 1.1liboptmysqlcppconn.lib"
Output file is binDebugmysql_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:DevelopmentCompilerMingWbingdb.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:WindowsSysWOW64KernelBase.dll)
#13 0x00401468 in _fu1___ZSt4cout () at D:DevelopmentProjectscodeblocksmysql_connectmain.cpp:13
D:DevelopmentProjectscodeblocksmysql_connectmain.cpp:13:252:beg:0x401468
At D:DevelopmentProjectscodeblocksmysql_connectmain.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");
有人能帮忙吗?
con = driver->connect("TCP:://127.0.0.1:3306", "test", "test");
你有上面的一个,MySQL网站有下面的代码。
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
我看不出有多大区别。你确定用户名、密码和端口与你在代码中提到的相同吗?
好的!问题出在我的IDE上。似乎MySQL Connector C++ 1.1.4
仅适用于Microsoft Visual C++ 2003
或更高版本。
若您有同样的问题,只需安装Microsoft Visual C++ 2003
或更新版本并正确链接库。http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows-visual-studio.html
相关文章:
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 使用mysql c++连接器的未定义引用
- MySQL C++连接器链接错误
- C++ boost::asio::ip::tcp::acceptor 有时不接受连接器?
- C++MySQL连接器没有utf8
- 如何在连接器 C++ 中将原始字节转换为字符串
- MySQL 连接器/C++.尝试在此过程中停止连接到数据库
- 获取具有字段名称的 SELECT 字段类型,并带有 MariaDB C++连接器
- 如何使用连接器 c++ 在 mySQL 表二进制(16) 字段中存储 c++ 字节数组?
- MySQL C++连接器循环
- MySQL c++ 连接器:使用 SetBlob() 在查询中设置多个 blob 数据的正确方法是什么?
- 在 C/C++ 中使用 MySQL 连接器执行插入到表时出错
- 无法在我的ubuntu中正确安装MySQL连接器/c++
- 在 MySQL 连接器C++ API 中使用一个函数调用执行多个查询的正确方法是什么?
- mysql c ++连接器异常:用户"root"@'localhost'的访问被拒绝(使用密码:NO)&&MySQL服务器已消失
- MySQL 连接器 CPP 在 CentOS 6 中未定义的引用
- 在Windows上编译MariaDB C/C++连接器
- MySQL C++连接器:添加符号时出错:文件格式无法识别
- 如何使用mysqlc++连接器插入查询
- EXE在编译后停止工作.(MysqlC++连接器)