Author: tbedford
Date: 2009-03-31 18:48:18 +0200 (Tue, 31 Mar 2009)
New Revision: 14439
Log:
Initial details of building C/C++ applications on Windows.
Modified:
trunk/refman-common/connector-cpp.xml
Modified: trunk/refman-common/connector-cpp.xml
===================================================================
--- trunk/refman-common/connector-cpp.xml 2009-03-31 16:44:54 UTC (rev 14438)
+++ trunk/refman-common/connector-cpp.xml 2009-03-31 16:48:18 UTC (rev 14439)
Changed blocks: 2, Lines Added: 349, Lines Deleted: 0; 11342 bytes
@@ -929,6 +929,297 @@
</section>
+ <section id="connector-cpp-using-windows">
+
+ <title>&ccpp; Building applications on Windows</title>
+
+ <para>
+ &ccpp; is available as a static or dynamic library to use with
+ your application. This section looks at how to link the library to
+ your application.
+ </para>
+
+ <para>
+ <emphasis role="bold">Static library</emphasis>
+ </para>
+
+ <para>
+ The &ccpp; static library file is
+ <filename>mysqlcppconn-static.lib</filename>. This needs to be
+ statically linked with your application. You also need to link
+ against the files <filename>libmysql.dll</filename> and
+ <filename>libmysql.lib</filename>. Once linking has been
+ successfully completed, the application will require access to
+ <filename>libmysql.dll at run time.</filename>
+ </para>
+
+ <para>
+ <emphasis role="bold">Dynamic library</emphasis>
+ </para>
+
+ <para>
+ The &ccpp; dynamic library file is
+ <filename>mysqlcppconn.dll</filename>. In order to build your
+ client application you need to link it with the file
+ <filename>mysqlcppconn.lib</filename>. At run time the application
+ will require access to the files
+ <filename>mysqlcppconn.dll</filename> and
+ <filename>libmysql.dll</filename>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Building an application using the static
+ library - step-by-step</emphasis>
+ </para>
+
+ <orderedlist>
+
+ <listitem>
+ <para>
+ Select <guimenu>File</guimenu>, <guimenu>New</guimenu>,
+ <guimenu>Project</guimenu> from the main menu. Then in the
+ wizard select <guilabel>Visual C++</guilabel>,
+ <guilabel>Win32</guilabel>. From <guilabel>Visual Studio
+ Installed Templates</guilabel> select the application type
+ <guilabel>Win32 Console Application</guilabel>. Enter a name
+ for the application, and then click <guibutton>OK</guibutton>,
+ to move to the Win32 Application Wizard.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ In the Win32 Application Wizard, click on
+ <guilabel>Application Settings</guilabel> and ensure the
+ defaults are selected. The radio button <guilabel>Console
+ application</guilabel>, and the checkbox <guilabel>Precompiled
+ headers</guilabel> will be selected.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ From the drop down list box on the toolbar, change from the
+ default <guilabel>Debug</guilabel> build to the
+ <guilabel>Release</guilabel> build.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ From the main menu select <guimenu>Project</guimenu>,
+ <guimenu>Properties</guimenu>. This can also be accessed using
+ the hot key <guibutton>ALT</guibutton> +
+ <guibutton>F7</guibutton>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Under <guilabel>Configuration Properties</guilabel>, open the
+ tree view.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Select <guimenu>C++</guimenu>, <guilabel>General</guilabel> in
+ the tree view. Then in the <guilabel>Additional Include
+ Directories</guilabel> text field, add
+ <filename>include/</filename>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ In the same tree view under <guilabel>Linker</guilabel>,
+ <guilabel>General</guilabel>, add <filename>lib/opt</filename>
+ into the <guilabel>Additional Library Directories</guilabel>
+ text field.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Also in <guilabel>Linker</guilabel>,
+ <guilabel>General</guilabel>, <guilabel>Additional Library
+ Directories</guilabel>, add MySQL Server
+ <filename>lib/opt</filename> for
+ <filename>libmysql.lib</filename>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Then in <guilabel>Linker</guilabel>,
+ <guilabel>Input</guilabel>, <guilabel>Additional
+ Dependencies</guilabel>, enter
+ <filename>mysqlcppconn-static.lib</filename> and
+ <filename>libmysql.lib</filename>.
+ </para>
+
+<programlisting>
+------ Rebuild All started: Project: cpp_static_client, Configuration: Release Win32 ------
+Deleting intermediate and output files for project 'cpp_static_client', configuration 'Release|Win32'
+Compiling...
+cpp_static_client.cpp
+stdafx.cpp
+Linking...
+cpp_static_client.obj : error LNK2001: unresolved external symbol __imp__get_driver_instance
+cpp_static_client.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
+ public: int __thiscall sql::SQLException::getErrorCode(void)const "
+ (__imp_?getErrorCode@SQLException@sql@@QBEHXZ)
+cpp_static_client.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
+ public: class std::basic_string<char,struct std::char_traits<char>,
+ class std::allocator<char> > const & __thiscall
+ sql::SQLException::getSQLState(void)const "
+ (__imp_?getSQLState@SQLException@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
+C:\Dokumente und Einstellungen\T60\Eigene Dateien\Visual Studio 2008\Projects
+ \cpp_static_client\Release\cpp_static_client.exe : fatal error LNK1120: 3 unresolved externals
+Build log was saved at "file://c:\Dokumente und Einstellungen\T60\Eigene Dateien\Visual Studio 2008\
+ Projects\cpp_static_client\cpp_static_client\Release \BuildLog.htm"
+cpp_static_client - 4 error(s), 0 warning(s)</programlisting>
+ </listitem>
+
+ <listitem>
+ <para>
+ In the <guilabel>Project</guilabel>,
+ <guilabel>Properties</guilabel> tree view, under
+ <guilabel>C++</guilabel>, <guilabel>Preprocessor</guilabel>,
+ enter <literal>CPPCONN_PUBLIC_FUNC=</literal> into the
+ <guimenu>Preprocessor Definitions</guimenu> text field.
+ </para>
+ </listitem>
+
+ </orderedlist>
+
+ <para>
+ <emphasis role="bold">Building an application to use the dynamic
+ library - step-by-step</emphasis>
+ </para>
+
+ <orderedlist>
+
+ <listitem>
+ <para>
+ From the main menu select <guimenu>File</guimenu>,
+ <guimenu>New Project</guimenu>. Then in the wizard select
+ <guilabel>Visual C++</guilabel>, <guilabel>Win32</guilabel>.
+ Under <guilabel>Visual Studio installed templates</guilabel>
+ select <guimenu>Win32 Console Application</guimenu>. Enter a
+ suitable name, and then click <guibutton>OK</guibutton> to
+ enter the Win32 Application wizard.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ In the Win32 Application Wizard, click on
+ <guilabel>Application Settings</guilabel>. Use the default
+ settings. The <guilabel>Console application</guilabel> radio
+ button, and <guilabel>Precompiled header</guilabel> checkbox
+ should be selected. Click <guibutton>Finish</guibutton> to
+ close the wizard.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ From the drop down list box on the toolbar, change from the
+ default <guilabel>Debug</guilabel> build to the
+ <guilabel>Release</guilabel> build.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ From the main menu select <guimenu>Project</guimenu>,
+ <guimenu>Properties</guimenu>. This can also be accessed using
+ the hot key <guibutton>ALT</guibutton> +
+ <guibutton>F7</guibutton>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Under <guilabel>Configuration Properties</guilabel>, open the
+ tree view.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Under <guilabel>C++</guilabel>, <guilabel>General</guilabel>,
+ add <filename>include/</filename> into the <guimenu>Additional
+ Include Directories</guimenu> text field.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Under <guilabel>Linker</guilabel>,
+ <guilabel>General</guilabel>, add <filename>lib/opt</filename>
+ into the <guimenu>Additional Library Directories</guimenu>
+ text field.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Under <guilabel>Linker</guilabel>, <guilabel>Input</guilabel>,
+ add <filename>mysqlcppconn.lib</filename> into the
+ <guilabel>Additional Dependencies</guilabel> text field.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ In the <guimenu>Editor</guimenu>, copy
+ <filename>standalone_example_docs1.cpp</filename>, and add
+ <literal>#include "stdafx.h"</literal> at the top of the file.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ From the main menu select <guimenu>Build</guimenu>,
+ <guimenu>Build Solution</guimenu>, to build the solution.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Open a command prompt by selecting <guimenu>Start</guimenu>,
+ <guimenu>Execute</guimenu>, and entering
+ <literal>cmd</literal>. Go to the <filename>build</filename>
+ directory for the project, and change into the
+ <filename>Release</filename> directory.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Run the application. You will receive an error: <quote>cannot
+ find <filename>mysqlcppconn.dll</filename></quote>.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Copy <filename>mysqlcppconn.dll</filename> to the working
+ directory or extend the <literal>PATH</literal> environment
+ variable using <literal>SET
+ PATH=%PATH%;C:\path\to\cpp</literal>. Alternatively, you can
+ copy <filename>mysqlcppconn.dll</filename> to the Windows
+ installation Directory, typically
+ <filename>c:\windows</filename>.
+ </para>
+ </listitem>
+
+ </orderedlist>
+
+ </section>
+
<section id="connector-cpp-getting-started-examples">
<title>&ccpp; Getting Started: Usage Examples</title>
@@ -2117,4 +2408,62 @@
</section>
+ <section id="connector-cpp-faq">
+
+ <title>&ccpp; FAQ</title>
+
+ <qandaset>
+
+ <qandaentry>
+
+ <question>
+
+ <para></para>
+
+ </question>
+
+ <answer>
+
+ <para></para>
+
+ </answer>
+
+ </qandaentry>
+
+ <qandaentry>
+
+ <question>
+
+ <para></para>
+
+ </question>
+
+ <answer>
+
+ <para></para>
+
+ </answer>
+
+ </qandaentry>
+
+ <qandaentry>
+
+ <question>
+
+ <para></para>
+
+ </question>
+
+ <answer>
+
+ <para></para>
+
+ </answer>
+
+ </qandaentry>
+
+ </qandaset>
+
+ </section>
+
</section>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r14439 - trunk/refman-common | anthony.bedford | 31 Mar |