Visual Studio配置MySql数据库

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++能做为项目的静态或动态库,这章节就是描述如何链接该库到你的项目中。

Note

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.

  1. Select File, New, Project from
    the main menu.

    Figure 5.1 Creating a New Project

  2. 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 OK, to move to the Win32
    Application Wizard.

    Figure 5.2 The New Project Dialog Box

  3. 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 Finish to close the wizard.

    Figure 5.3 The Win32 Application Wizard

  4. 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

  5. From the main menu select Project, Properties.
    This can also be accessed using the hot key ALT + F7.

    Figure 5.5 Selecting Project Properties from the Main Menu

  6. Under Configuration Properties, open the tree
    view.
  7. Select C++, General in
    the tree view.

    Figure 5.6 Setting Properties

  8. 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

  9. In the Additional Include Directories text
    field, add the MySQL include/ directory.

    Figure 5.8 Select Directory Dialog

  10. 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

  11. In the tree view, open Linker, General, Additional
    Library Directories.

    Figure 5.10 Additional Library Directories

  12. 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:

  1. Open Linker, Input, Additional
    Dependencies.

    Figure 5.12 Additional Dependencies

  2. Enter mysqlcppconn-static.lib and libmysql.lib.

    Figure 5.13 Adding Additional Dependencies

  3. 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, define CPPCONN_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 thePreprocessor
    Definitions text field.

    Figure 5.14 Setting the CPPCONN_PUBLIC_FUNC Define

    Note

    Make sure you enter CPPCONN_PUBLIC_FUNC= and
    not CPPCONN_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:

  1. Under Linker, Input,
    add mysqlcppconn.lib into the Additional
    Dependencies text field.
  2. 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 the PATH environment
    variable using SET PATH=%PATH%;C:\path\to\cpp.
    Alternatively, you can copy mysqlcppconn.dll to the Windows
    installation Directory, typically c:\windows.

时间: 2024-10-06 03:57:07

Visual Studio配置MySql数据库的相关文章

Visual Studio下SQLite数据库开发环境设置

因为我们介绍的内容都是基于微软的Visual Studio下开发的Win32平台,所以下边我们介绍Visual Studio下SQLite数据库开发环境设置. 详细而言我们有两种方式能够在Visual Studio中SQLite数据库:使用SQLite源码文件和使用Cocos2d-x提供的库文件.1.使用SQLite源码文件SQLite是C编写的开源的数据库,我们能够在http://www.sqlite.org/download.html网址下载最新的SQLite源码,如我下载的sqlite-a

学习时用的软件最新 开发环境为Visual Studio 2010,数据库为SQLServer2005,使用.net 4.0开发。 超市管理系统

一.源码特点 1.采用典型的三层架构进行开发.模板分离,支持生成静态 伪静态..购物车.登陆验证.div+css.js等技术二.功能介绍 1.本源码是一个超市在线购物商城源码,该网上商城是给超市便利店等零售批发实体店定制的网上商城,主要针对周边配送,后台可定义配送范围,可在线支付和货到付款! 2.用户注册,需要填写正确手机号码 获得验证码输入正确才能注册成功,保证用户信息的准确性,真实性.其它在线购物商城的常规功能,该系统都有,非常适合学习或二次开发使用,欢迎下载三.菜单功能       前台页

SpagoBI4.2汉化及配置Mysql数据库教程

SpagoBI4.2汉化及配置Mysql数据库教程 1.安装Mysql数据库 2.安装JDK并配置JAVA环境变量 3.下载SapagoBI4.2 allinone 安装包 4.解压缩SpagoBI安装包到E盘BI文件夹下 5.配置系统环境变量:CATALINA_HOME,路径为E:\BI\SpagoBI-Server-4.2-10042014 6.启动安装目录E:\BI\SpagoBI-Server-4.2-10042014\bin下的SpagoBIStartup.bat文件,当出现serve

django配置mysql数据库

安装完python后,安装python-mysql来连接mysql数据库,下载地址http://sourceforge.net/projects/mysql-python/,安装很简单,点下一步就可以了,不过要装和你python版本相对应的版本,否则比较蛋疼 安装完成后,配置下django的数据库连接,打开项目的配置文件settings.py,修改DATABASES参数 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql'

Linux CentOS下安装、配置mysql数据库

如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲解了Linux学习之CentOS(七)--CentOS下j2ee环境搭建),如果要开发web项目,我们当然可以安装一个myeclipse到Linux系统上去,这个安装方法和安装eclipse完全相同,就没有记录下来了,有了jdk.tomcat.eclipse我们就已经能进行我们的程序开发了,但是如果要做一个项目,哪怕是小的不能再小的项目都离不开数

intelliJ IDEA 配置MySQL数据库 详解

1> 在主界面中,点击右边侧栏的 Database ,在点击 + ,再Data Source 选择数据库 2> 填入 Database 数据库名,在输入 User 和 Password ,点击 Test Connection 3> 这样表示数据库连接成功 4> 这样就会看到数据库连接成功 很多人认为配置 Database 就是为了有一个 GUI 管理数据库功能,但是这并不是 IntelliJ IDEA 的 Database 最重要特性.数据库的 GUI 工具有很多,IntelliJ

Visual Studio 单元测试之五---数据库测试

原文:Visual Studio 单元测试之五---数据库测试 数据库的单元测试主要是测试数据库中的数据是否符合特定的条件,Visual Studio 2010支持下面几种数据的单元测试类型(Visual Studio 2008 不支持数据库测试): 类型 说明 Data Checksum 对数据进行Checksum检验 Empty ResultSet 测试执行的SQL语句返回结果集是否为空 Execution Time 测试执行时间 Expected Schema 测试结果集中的列和数据类型是

配置MySQL数据库详细步骤

一.配置MySQL数据库 1.解压绿色版mysql,如下图 二.安装服务 1.运行cmd(管理员版本,否则没有权限),如下图 2.运行命令mysqld –install安装服务,如下图: 如果不需要mysql里,只需要运行mysqld –remove即可移除,如下图 3.运行net start mysql 启动服务,如下图 如需要配置是否开机启动mysql可以在windows服务里面配置. 三.客户端测试 1.mysql –uroot –p 如下图 四.配置编码为UTF-8 1.在mysql5.

CentOS 6.5系统中RPM安装配置MySQL数据库

一.mysql简介 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内, 这样就增加了速度并提高了灵活性.MySQL的SQL语言是用于访问数据库的最常用标准化语言.MySQL软件采用了双授权政策(本词条"授权政策"), 它分为社区版和商业版,由于其体积小.速度快.总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作