Advertisement
ASP_Volume3 String Manipulation #65588

C++ MySQL++ Tutorial

At the request of "Karthik A" I am posting an in depth tutorial on the use of VC++ & MySQL++ development. I will take you through it step by step so that you may get your applications up and running as quickly as possible. http://johnstowncomputer.com

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

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