Visual Studio配置MySql数据库
来源:互联网 发布:网络固定电话怎么装 编辑:程序博客网 时间:2024/05/16 18:55
MySQL Connector/C++ is available as a static or dynamic library to use with your application. This section describes how to link the library to your application.
MySQL Connector/C++能做为项目的静态或动态库,这章节就是描述如何链接该库到你的项目中。
To avoid potential crashes, the build configuration of MySQL Connector/C++ should match the build configuration of the application using it. For example, do not use the release build of MySQL Connector/C++ with a debug build of the client application.
Static Library
The MySQL Connector/C++ static library file is mysqlcppconn-static.lib
. You link this library statically with your application. Also link against the files libmysql.dll
and libmysql.lib
. At runtime, the application will require access to libmysql.dll
.
Dynamic Library
The MySQL Connector/C++ dynamic library file is mysqlcppconn.dll
. To build your client application, link it with the file mysqlcppconn.lib
. At runtime, the application will require access to the files mysqlcppconn.dll
andlibmysql.dll
.
Building a MySQL Connector/C++ Application with Microsoft Visual Studio
The initial steps for building an application to use either the static or dynamic library are the same. Some additional steps vary, depend on whether you are building your application to use the static or dynamic library.
Select
, , from the main menu.Figure 5.1 Creating a New Project
In the wizard, select Visual C++, Win32. From Visual Studio Installed Templates, select the application typeWin32 Console Application. Enter a name for the application, then click , to move to the Win32 Application Wizard.
Figure 5.2 The New Project Dialog Box
In the Win32 Application Wizard, click Application Settings and ensure the defaults are selected. The radio button Console application and the check box Precompiled headers are selected. Click to close the wizard.
Figure 5.3 The Win32 Application Wizard
From the drop down list box on the toolbar, change from the default Debug build to the Release build.
Figure 5.4 Selecting the Release Build
From the main menu select
, . This can also be accessed using the hot key + .Figure 5.5 Selecting Project Properties from the Main Menu
Under Configuration Properties, open the tree view.
Select General in the tree view.
,Figure 5.6 Setting Properties
Ensure that Visual Studio can find the MySQL include directory. This directory includes header files that can optionally be installed when installing MySQL Server.
Figure 5.7 MySQL Include Directory
In the Additional Include Directories text field, add the MySQL
include/
directory.Figure 5.8 Select Directory Dialog
Also set the location of additional libraries that Visual Studio needs to build the application. These are located in the MySQL
lib/opt
directory, a subdirectory of the MySQL Server installation directory.Figure 5.9 Typical Contents of MySQL lib/opt Directory
In the tree view, open Linker, General, Additional Library Directories.
Figure 5.10 Additional Library Directories
Add the
lib/opt
directory into the Additional Library Directories text field. This enables the library filelibmysql.lib
to be found.Figure 5.11 Additional Library Directories Dialog
Static Build
The remaining steps depend on whether you are building an application to use the MySQL Connector/C++ static or dynamic library. If you are building your application to use the dynamic library, see Dynamic Build. If you are building your application to use the static library, carry out the following steps:
Open Linker, Input, Additional Dependencies.
Figure 5.12 Additional Dependencies
Enter
mysqlcppconn-static.lib
andlibmysql.lib
.Figure 5.13 Adding Additional Dependencies
By default
CPPCONN_PUBLIC_FUNC
is defined to declare functions to be compatible with an application that calls a DLL. If you are building an application to call the static library, ensure that function prototypes are compatible with this. In this case, defineCPPCONN_PUBLIC_FUNC
to be an empty string, so that functions are declared with the correct prototype.In the Project, Properties tree view, under C++, Preprocessor, enter
CPPCONN_PUBLIC_FUNC=
into the text field.Figure 5.14 Setting the CPPCONN_PUBLIC_FUNC Define
NoteMake sure you enter
CPPCONN_PUBLIC_FUNC=
and notCPPCONN_PUBLIC_FUNC
, so that it is defined as an empty string.
Dynamic build
If you are building an application to use the MySQL Connector/C++ dynamically linked library, carry out these steps:
Under Linker, Input, add
mysqlcppconn.lib
into the Additional Dependencies text field.mysqlcppconn.dll
must be in the same directory as the application executable, or somewhere on the system's path, so that the application can access the MySQL Connector/C++ Dynamic Linked Library at runtime.Copy
mysqlcppconn.dll
to the same directory as the application. Alternatively, extend thePATH
environment variable usingSET PATH=%PATH%;C:\path\to\cpp
. Alternatively, you can copymysqlcppconn.dll
to the Windows installation Directory, typicallyc:\windows
.
- Visual Studio配置MySql数据库
- Visual Stdio 配置 MySql 数据库
- Visual Studio 2005 连接mysql数据库实例
- Visual Studio 2013 连接MySQL数据库
- MySQL++在Visual studio 2005上配置
- 用Visual Studio配置python的mysql
- visual studio 2010 MFC通过ODBC连接MYSQL数据库
- visual studio 2010 MFC通过ODBC访问MySQL数据库
- Visual studio 2013 连接MySQL数据库的设置
- visual studio 之 mysql 的配置及使用举例
- Visual Studio 环境配置
- visual studio字体配置
- boost 配置 Visual studio
- Visual Studio配置OpenGL
- OpenGL配置 visual studio
- Visual Studio配置OpenSSL
- visual studio配置openGL
- Visual Studio Code配置
- Metasploit常用方法以及名词解释
- Java集合框架中的接口和实现类
- 简单原始JS实现信息提示及隐藏
- 变-颓势下的凤凰涅槃-发表于程序杂志第12期
- buildroot2014.08交叉编译器的配置
- Visual Studio配置MySql数据库
- C++ 结构体嵌套、空结构体和空类
- 信息熵的直观理解
- 第十七周项目四-1日期结构体
- 使用 XHTML 的局限有哪些?如果页面使用 'application/xhtml+xml' 会有什么问题吗?
- Unique Paths II
- spring security3.x学习(22)_关于ip的过滤器
- 南阳oj 第15题 括号匹配(二)
- ACM必须掌握的算法