Lets begin with what you will need.
- MySQL database installed to C:\mysql
- Visual C++ .NET 2003
- MinGW 5.0 [http://sourceforge.net/forum/forum.php?forum_id=539405
- MySQL ++ Source 2.0.7 tarball [http://tangentsoft.net/mysql++]
Optional Components to assist development:
- PHP & MySQL enabled web server
- phpMyAdmin to assist database management
Lets begin. I am going to assume that you have mysql installed and running
to C:\mysql and MySQL ++ extraced to C:\mysql++.
MySQL++ only builds under Visual C++ 7.1 (a.k.a. Visual Studio
2003, a.k.a. cl version 13.10) or later. Earlier versions did
not support a sufficiently broad set of the Standard C++ language.
About the New Build System (makemake)
As of MySQL++ v2.0, we have changed the VC++ build system over to
a command-line based system, instead of Visual Studio project
files. We've done this for many reasons:
1. Not everyone has the IDE: Microsoft has made their
command-line tools available for free at various times,
and these offers usually do not include the Visual
2. Project files tend to be tied to one version of
Visual Studio. Newer versions can migrate old project
files, but then old versions cannot read the new files.
So, each time there's a new version of Visual Studio,
there's a transition period where at least two versions
of the IDE are still in common use. Makefiles,
by contrast, work with all versions, without changes.
3. Standardization: project files types proliferated
in the old system, and we would frequently forget to
update all of the project files when changing the
corresponding autotools files. In the new system,
there are only two places where build system changes
need to be made: one for systems using the autotools,
and one for systems using makemake.
So, please do not ask for the Visual Studio project files to
return. They cause more problems than they solve.
Prerequisite: GNU make
The Makefiles generated by makemake require GNU make.
They used to work with Microsoft's nmake, but that held us
back from adding several useful features.
We've tested with two ports of GNU make for Windows: Cygwin and
To get GNU make through Cygwin, go to http://cygwin.com/ and
get the Cygwin setup program. GNU make isn't part of the
default installation, so you will have to add it. It's in
the Devel category.
To get the MinGW version of GNU make, go to http://mingw.org/
and download it directly. You shouldn't need to download
anything but the GNU make package, as it should run standalone.
Once you have done either of these, you will need to add
the bin directory containing GNU make to your PATH. If you
don't know how to do this, open Windows Help and search for
Building the Library and Example Programs
First, you need to open a Windows command prompt (cmd.exe).
The easiest way to do this is to go into your Visual Studio
program group under the Start menu and in the Tools folder
find the Command Prompt item. All it does is open a command
window and run a batch file called vcvars32.bat to set
up the environment variables needed to run the Visual C++
command-line tools. If you have a different way to open a
command prompt that you prefer, you can use that and run the
vcvars32.bat file by hand.
To create the Makefiles, say "makemake vc" in the mysql++ root
directory. You only have to do this once, unless you change
Makefile.base or Makefile.vc.
Now you can run GNU make to build the library and examples.
If you've installed GNU make through Cygwin, the command is
"make". If you're using the MinGW version of GNU make, it's
"mingw32-make"[mingw32-make is the command you will use] instead.
The build process creates debug and release versions of the MySQL++
DLL, as well as import libraries for those DLLs. It's possible to
create a static library, but we don't do this in the distributed
Makefiles because linking to such a library is a license violation
for programs not licensed under the GPL or LGPL. Using the
library in DLL form avoids this problem.
The build process also builds the example programs. They are built
in debug mode. You should run the major examples to make sure
the library is built correctly; see examples/README details.
Once the library is built and you're satisfied that it's working
correctly, say "install vc" [only under w32 install is a batch file that will
install your release libs and DLLs to a sub directory of mysql++ ]
at the project root.
If you didn't install MySQL in c:\mysql, you will have to change
Makefile.vc in the lib and examples sub directories and re-run
"makemake vc". You may also look at changing these files for
various other reasons, such as if you don't like the way we name
the DLL file, or want the 'install' target to put the MySQL++
development files somewhere other than c:\mysql++.
Using MySQL++ in Your Own Projects
Fire up VS .NET, create a Blank Solution. Add a new project.
Choose Empty Project (.NET) under Visual C++ Projects. Add a
.cpp file to the solution so it _knows_ it's a C/C++ solution.
Go to the solution Property Pages and make the following changes.
(Where it doesn't specify Debug or Release, make the change to
o Under Configuration Properties::General change "Use
Managed Extensions" to "No"
o Under C/C++::General add to "Additional Include
Directories": c:\mysql++\include, c:\mysql\include
o Under C/C++::Code Generation change "Runtime Library" to
"Multi-threaded Debug DLL (/MDd)" for the Debug
configuration. For the Release configuration, make it
"Multi-threaded DLL (/MD)".
o Under Linker::General add to "Additional Library
Directories": "c:\mysql\lib\debug, c:\mysql++\vc\debug"
for the Debug configuration. For the Release configuration,
make it "c:\mysql\lib\opt, c:\mysql++\vc\release"
o Under Linker::Input add to "Additional Dependencies":
"libmysql.lib wsock32.lib mysqlpp.lib"
If You Run into Problems...
Especially if you have linking problems, make sure your project
settings match the above. Visual C++ is very picky about things
like run time library settings. If you still can't get things
going, try running one of the example programs. If it works,
the problem is likely in your project settings, not in MySQL++.
Final Note: To run the application ou will need to copy the
proper DLL from the mysql++ directory to your debug or
release folder within your visual studio project, or you may
add the location to your library path. I suggest simply copying
Providing you installed everything to the location I have specified,
the paths to the important DLLs are as follows:
mysqlpp.dll for debug builds :C:\mysql++\vc\debug
mysqlpp.dll for release builds :C:\mysql++\vc\release
libmysql.dll for debug builds: C:\mysql\lib\debug
libmysql.dll for release builds: C:\mysql\lib\opt
Please send any questions to me anytime at email@example.com