MySQL Forums
Forum List  »  Connector/C++

Re: connector installation for dummies required
Posted by: Ulf Wendel
Date: November 20, 2008 02:53PM

Hi!

I must confess that I have not gone through *all* steps on Windows myself yet. You are waiting for "Building and debugging MySQL Connector/C++" (http://blog.ulf-wendel.de/?p=204) to be finished and published :-). Sorry its not yet done and has not yet been published. If you can wait a few days, please wait.

However, the basic installation procedure is outlined at http://blog.ulf-wendel.de/?p=202 (paragraph Getting Connector/C++). There is no graphical installer yet and you need to go through all steps manually.

Skip the preview and get the latest source from Launchpad (see blog), its almost the code of the alpha release. Again, I must confess that I have not yet tried the Windows bazaar client myself but it should work just fine. Grab it from https://launchpad.net/bzr/+download .

Now you will need CMake from cmake.org . CMake is there to create build files, for example for Visual Studio. But CMake can also generate build files for GNU make and others. CMake comes with many "Generators". The available "Generators" may vary from CMake version to version.

Last but not least you need the MySQL Server and its Client Library. The Connector/C++ will be linked against the Client Library.

Once you got everything compiling should be easy going. From the to be published blog posting:

First you invoke CMake to generate build files, for example, for Visual C++ 2008 Express Edition. Then you either compile the Connector on the command line or open the Solution resp. Projects in the GUI.

C:\Dokumente und Einstellungen\T60\cpp_trunk>cmake -G "Visual Studio 9 2008"
-- Check for working C compiler: cl
-- Check for working C compiler: cl -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: cl
-- Check for working CXX compiler: cl -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- ENV{MYSQL_DIR} =
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library : C:/Programme/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib
-- MySQL Library dir: C:/Programme/MySQL/MySQL Server 5.1/lib/opt
-- MySQL CFLAGS:
-- MySQL Link flags:
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library dir: C:/Programme/MySQL/MySQL Server 5.1/lib/opt
-- MySQL CFLAGS:
-- MySQL Link flags:
-- Configuring cppconn
-- Configuring test cases
-- Looking for isinf
-- Looking for isinf - not found
-- Looking for isinf
-- Looking for isinf - not found.
-- Looking for finite
-- Looking for finite - not found.
-- Configuring C/J junit tests port
-- Configuring examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Dokumente und Einstellungen/T60/cpp_trunk
C:\Dokumente und Einstellungen\T60\cpp_trunk>dir *.sln *.vcproj
[...]
19.11.2008 12:16 23.332 MYSQLCPPCONN.sln
[...]
19.11.2008 12:16 27.564 ALL_BUILD.vcproj
19.11.2008 12:16 27.869 INSTALL.vcproj
19.11.2008 12:16 28.073 PACKAGE.vcproj
19.11.2008 12:16 27.495 ZERO_CHECK.vcproj

At this point my blog draft ends :-( and I'm not the Windows guy in our little development team. I'll try to give a few additional pointers but I will also need to ask a co-worker to help out once he wakes up.

The above example show the procedure of generating build files for VS 9 / 2008. However, check cmake --help to see the syntax you need for your compiler.

C:\Dokumente und Einstellungen\T60\cpp_trunk>cmake --help
cmake version 2.6-patch 2
Usage
[...]
Generators

The following generators are available on this platform:
Borland Makefiles = Generates Borland makefiles.
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
NMake Makefiles = Generates NMake makefiles.
Unix Makefiles = Generates standard UNIX makefiles.
Visual Studio 6 = Generates Visual Studio 6 project files.
Visual Studio 7 = Generates Visual Studio .NET 2002 project
files.
Visual Studio 7 .NET 2003 = Generates Visual Studio .NET 2003 project
files.
Visual Studio 8 2005 = Generates Visual Studio .NET 2005 project
files.
Visual Studio 8 2005 Win64 = Generates Visual Studio .NET 2005 Win64
project files.
Visual Studio 9 2008 = Generates Visual Studio 9 2008 project files.
Visual Studio 9 2008 Win64 = Generates Visual Studio 9 2008 Win64 project
files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles= Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
= Generates Eclipse CDT 4.0 project files.


Once you got the build file, build the project/solution. You can do that either on the command line or simply open the project/solution in the IDE. I always used the IDE. There's a README in the source which contains a short note with hints for the command line based compile.

If CMake did not manage to find the MySQL Client Library on your system the build will fail. If so, you need to hint CMake where to find the Client Lib. Here is how you ask CMake which client lib it wants to link against:

C:\Dokumente und Einstellungen\T60\cpp_trunk>cmake -L
-- ENV{MYSQL_DIR} =
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library : C:/Programme/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib
-- MySQL Library dir: C:/Programme/MySQL/MySQL Server 5.1/lib/opt
-- MySQL CFLAGS:
-- MySQL Link flags:
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library dir: C:/Programme/MySQL/MySQL Server 5.1/lib/opt
-- MySQL CFLAGS:
-- MySQL Link flags:
-- Configuring cppconn
-- Configuring test cases
-- Configuring C/J junit tests port
-- Configuring examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Dokumente und Einstellungen/T60/cpp_trunk
-- Cache values
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_INSTALL_PREFIX:PATH=C:/Programme/MYSQLCPPCONN
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_INCLUDE_DIR:PATH=C:/Programme/MySQL/MySQL Server 5.1/include
MYSQL_LIB:FILEPATH=C:/Programme/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib

At the end you see:
MYSQL_LIB:FILEPATH=C:/Programme/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib


If your library (or the MySQL include files) is located somewhere else you can hint that to CMake using:

C:\Dokumente und Einstellungen\T60\cpp_trunk>cmake -DMYSQL_LIB:FILEPATH=C:\SpecialMySQL\lib\mysqlclient.lib
-- ENV{MYSQL_DIR} =
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library : C:/SpecialMySQL/lib/mysqlclient.lib
-- MySQL Library dir: C:/SpecialMySQL/lib
-- MySQL CFLAGS:
-- MySQL Link flags:
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library dir: C:/SpecialMySQL/lib
-- MySQL CFLAGS:
-- MySQL Link flags:
-- Configuring cppconn
-- Configuring test cases
-- Configuring C/J junit tests port
-- Configuring examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Dokumente und Einstellungen/T60/cpp_trunk

Verify that CMake got what you want to do:

C:\Dokumente und Einstellungen\T60\cpp_trunk>cmake -L
-- ENV{MYSQL_DIR} =
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library : C:/SpecialMySQL/lib/mysqlclient.lib
-- MySQL Library dir: C:/SpecialMySQL/lib
-- MySQL CFLAGS:
-- MySQL Link flags:
-- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
-- MySQL Library dir: C:/SpecialMySQL/lib
-- MySQL CFLAGS:
-- MySQL Link flags:
-- Configuring cppconn
-- Configuring test cases
-- Configuring C/J junit tests port
-- Configuring examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Dokumente und Einstellungen/T60/cpp_trunk
-- Cache values
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_INSTALL_PREFIX:PATH=C:/Programme/MYSQLCPPCONN
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_INCLUDE_DIR:PATH=C:/Programme/MySQL/MySQL Server 5.1/include
MYSQL_LIB:FILEPATH=C:/SpecialMySQL/lib/mysqlclient.lib

Great, CMake got it. Remember, you will need to go through this only if the automatic detection fails! We try to identify the MySQL installation automatically. To finish the excurse: del CMakeCache.txt (see blog!) , cmake -G "Whatever Generator you need" and compile again.

Now you got the Connector/C++ library. And you got a couple of examples (see blog). Existing examples are boring, you want to run your own program. Again, check the blog "Compiling your own program against Connector/C++". It has some pointers which header files your program needs to include. And of course, you'll need to link your program against the Connector/C++ library.

How to do that on Linux, see examples/standalone_example.cpp inline docs. How to do that on Windows, wait a few days for the next blog posting...

Hold on, maybe our Windows expert Lawrin will be faster and hook in tomorrow. I'll ping him.

Ulf

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: connector installation for dummies required
5672
November 20, 2008 02:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.