1<!--$Id: intro.so,v 10.79 2006/01/27 20:01:45 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Building for Windows</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<a name="2"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Building Berkeley DB for Windows systems</dl></b></td> 14<td align=right><a href="../build_unix/ultrix.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../build_win/small.html"><img src="../../images/next.gif" alt="Next"></a> 15</td></tr></table> 16<p align=center><b>Building for Windows</b></p> 17<p>This page contains general instructions on building Berkeley DB for 18specific windows platforms using specific compilers. The 19<a href="../../ref/build_win/faq.html">Windows FAQ</a> also 20contains helpful information.</p> 21<p>The <b>build_windows</b> directory in the Berkeley DB distribution contains 22project files for Microsoft Visual C++:</p> 23<table border=1 align=center> 24<tr><th>Project File</th><th>Description</th></tr> 25<tr> <td align=center>Berkeley_DB.dsw</td> <td align=center>Visual C++ 6.0 workspace</td> </tr> 26<tr> <td align=center>*.dsp</td> <td align=center>Visual C++ 6.0 projects</td> </tr> 27</table> 28<p>These project files can be used to build Berkeley DB for the following platforms: 29Windows NT/2K/XP/2003, Windows 98/ME and 64-bit Windows XP/2003.</p> 30<b>Building Berkeley DB for Windows NT/2K/XP/2003</b> 31<h4>Visual C++ .NET 2005</h4> 32<ol> 33<p><li>Choose <i>File -> Open -> Project/Solution...</i>. 34In the <b>build_windows</b>, select <b>Berkeley_DB</b> and click 35Open. 36<p><li>You will be prompted to convert the project files to current Visual C++ 37format. Select "Yes to All". 38<p><li>Choose the project configuration from the drop-down menu on the tool 39bar (usually Debug or Release for Win32). 40<p><li>To build, right-click on the build_all target and select Build. 41</ol> 42<h4>Visual C++ .NET or Visual C++ .NET 2003</h4> 43<p>This is very similar to the building with Visual Studio 2005, but some 44menu options have been rearranged:</p> 45<ol> 46<p><li>Choose <i>File -> Open Solution</i>. Look in the 47<b>build_windows</b> directory for compatible workspace files, select 48<b>Berkeley_DB.dsw</b>, and press Open. 49<p><li>You will be prompted to convert the project files to current Visual C++ 50format. Select "Yes to All". 51<p><li>Choose the project configuration from the drop-down menu on the .NET 52tool bar (Debug or Release). 53<p><li>To build, right-click on build_all and select Build. 54</ol> 55<h4>Visual C++ 6.0</h4> 56<ol> 57<p><li>Choose <i>File -> Open Workspace</i>. Look in the 58<b>build_windows</b> directory for Workspaces, select 59<b>Berkeley_DB.dsw</b>, and press Open. 60<p><li>Choose the desired project configuration by going to <i>Build 61-> Set Active Configuration</i> and select the appropriate option 62to the build_all project (Debug or Release). Then click OK. 63<p><li>To build, press F7. 64</ol> 65<h4>Build results</h4> 66<p>The results of your build will be placed in a subdirectory of 67<b>build_windows</b> named after the configuration you chose (for 68examples, <b>build_windows\Release</b> or 69<b>build_windows\Debug</b>).</p> 70<p>When building your application during development, you should normally 71use compile options "Debug Multithreaded DLL" and link against 72<b>build_windows\Debug\libdb47d.lib</b>. You can 73also build using a release version of the Berkeley DB libraries and tools, 74which will be placed in 75<b>build_windows\Release\libdb47.lib</b>. When 76linking against the release build, you should compile your code with 77the "Release Multithreaded DLL" compile option. You will also need to 78add the <b>build_windows</b> directory to the list of include 79directories of your application's project, or copy the Berkeley DB include 80files to another location.</p> 81<b>Building Berkeley DB for Windows 98/ME</b> 82<p>By default on Windows, Berkeley DB supports internationalized filenames by 83treating all directory paths and filenames passed to Berkeley DB methods as 84UTF-8 encoded strings. All paths are internally converted to wide 85character strings and passed to the wide character variants of Windows 86system calls.</p> 87<p>This allows applications to create and open databases with names that 88cannot be represented with ASCII names while maintaining compatibility 89with applications that work purely with ASCII paths.</p> 90<p>Windows 98 and ME do not support Unicode paths directly. To build for 91those versions of Windows, either follow the above instructions, 92choosing the "Debug ASCII" or "Release ASCII" build targets, or follow 93the instructions at 94<a href="http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx">Microsoft's web site</a>.</p> 95<p>The ASCII builds will also work on Windows NT/2K/XP and 2003, but will 96not translate paths to wide character strings.</p> 97<b>Building Berkeley DB for 64-bit Windows</b> 98<p>The following procedure can be used on either to build natively on a 9964-bit system or to cross-compile from a 32-bit system.</p> 100<h4>x64 build with Visual Studio 2005</h4> 101<ol> 102<p><li>Choose <i>File -> Open -> Project/Solution...</i>. 103In the <b>build_windows</b>, select <b>Berkeley_DB</b> and click 104Open. 105<p><li>You will be prompted to convert the project files to current Visual C++ 106format. Select "Yes to All". 107<p><li>Choose the project configuration from the drop-down menu on the tool 108bar ("Debug AMD64", "Release AMD64"). Change the CPU type from 109Win32 to x64. 110<p><li>Right-click on the build_all target and select Build. 111</ol> 112<h4>64-bit build with Visual Studio .NET 2003 or earlier</h4> 113<p>You will need latest Platform SDK from Microsoft, available from 114<a href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/">Microsoft's web site</a>. You only need the "Core SDK" from there.</p> 115<p>Once that is installed, you should have an entry in your Start Menu 116called <i>Microsoft Platform SDK (date) -> Open Build 117Environment Window -> Windows Server 2003 64-bit Build 118Environment -> Set Win Svr 2003 x64 Build Env (Debug)</i>. 119Selecting that will open a command window with the environment set up 120for 64-bit Windows development targeting AMD64-compatible CPUs.</p> 121<p>Depending on how your computer is configured, you may need to run the 122<b>vcvars32.bat</b> or script to set up the environment to build 123from the command line with Visual Studio.</p> 124<p>Then, in the <b>build_windows</b> directory in the Berkeley DB 125distribution, run this for Visual Studio .NET: 126<blockquote><pre>devenv Berkeley_DB.dsw</pre></blockquote> 127Choose "Yes To All" in the dialog box that appears, then close Visual 128Studio, then run: 129<blockquote><pre>devenv Berkeley_DB.sln /build "Debug AMD64" /project "build_all" /useenv</pre></blockquote> 130For Visual Studio 6, just run this instead: 131<blockquote><pre>msdev Berkeley_DB.dsw /make "build_all - Debug AMD64" /useenv</pre></blockquote> 132You should now have AMD64 binaries in the "Debug_AMD64" directory.</p> 133<p>To build a release, open the "Retail" window instead of the "Debug" 134window, and change Debug to Release in the above commands. To build 135for Itanium, change AMD64 and x64 to IA64.</p> 136<b>Building Berkeley DB with Cygwin</b> 137<p>To build Berkeley DB with Cygwin, follow the instructions in 138<a href="../../ref/build_unix/intro.html">Building for UNIX</a>.</p> 139<b>Building the C++ API</b> 140<p>C++ support is built automatically on Windows.</p> 141<b>Building the Java API</b> 142<p>Java support is not built automatically. The following instructions 143assume that you have installed the Sun Java Development Kit in 144<b>d:\java</b>. Of course, if you installed elsewhere or have 145different Java software, you will need to adjust the pathnames 146accordingly.</p> 147<h4>Building Java with Visual C++ .NET or above</h4> 148<ol> 149<p><li>Set your include directories. Choose <i>Tools -> Options 150-> Projects -> VC++ Directories</i>. Under the "Show 151directories for" pull-down, select "Include files". Add the full 152pathnames for the <b>d:\java\include</b> and 153<b>d:\java\include\win32</b> directories. Then click OK. These are 154the directories needed when including jni.h. 155<p><li>Set the executable files directories. Choose <i>Tools -> 156Options -> Projects -> VC++ Directories</i>. Under the "Show 157directories for" pull-down, select "Executable files". Add the full 158pathname for the <b>d:\java\bin</b> directory, then click OK. This is 159the directory needed to find javac. 160<p><li>Set the build type to Release or Debug in the drop-down on the .NET 161tool bar. 162<p><li>To build, right-click on db_java and select Build. This builds the 163Java support library for Berkeley DB and compiles all the java files, 164placing the resulting <b>db.jar</b> and <b>dbexamples.jar</b> 165files in the <b>build_windows\Release</b> or 166<b>build_windows\Debug</b> subdirectory of Berkeley DB. 167</ol> 168<h4>Building Java with Visual C++ 6.0</h4> 169<ol> 170<p><li>Set the include directories. Choose <i>Tools -> Options 171-> Directories</i>. Under the "Show directories for" pull-down, 172select "Include files". Add the full pathnames for the 173<b>d:\java\include</b> and <b>d:\java\include\win32</b> directories. 174These are the directories needed when including <b>jni.h</b>. 175<p><li>Set the executable files directories. Choose <i>Tools -> 176Options -> Directories</i>. Under the "Show directories for" 177pull-down, select "Executable files". Add the full pathname for the 178<b>d:\java\bin</b> directory. This is the directory needed to find 179javac. 180<p><li>Go to <i>Build -> Set Active Configuration</i> and select 181either the Debug or Release version of the db_java project. Then 182press OK. 183<p><li>To build, select <i>Build -> Build 184libdb_java47.dll</i>. This builds the Java support 185library for Berkeley DB and compiles all the java files, placing the 186resulting <b>db.jar</b> and <b>dbexamples.jar</b> files in the 187<b>build_windows\Release</b> or <b>build_windows\Debug</b> 188subdirectory of Berkeley DB. 189</ol> 190<p>To run Java code, set your environment variable <b>CLASSPATH</b> 191to include the full pathname of these jar files, and your environment 192variable <b>PATH</b> to include the <b>build_windows\Release</b> 193subdirectory. On Windows, remember that files or directories in the 194<b>CLASSPATH</b> and <b>PATH</b> variables must be separated 195by semicolons (unlike UNIX). Then, try running the following command 196as a test:</p> 197<blockquote><pre>java db.AccessExample</pre></blockquote> 198<p>If you want to run Java code using a Debug build, substitute 'Debug' 199for 'Release' in the instructions above. Make sure you use the Debug 200JAR file with the Debug DLL and the Release JAR with the Release 201DLL.</p> 202<b>Building the Tcl API</b> 203<p>Tcl support is not built automatically. See 204<a href="../../ref/tcl/intro.html">Loading Berkeley DB with Tcl</a> for 205information on sites from which you can download Tcl and which Tcl 206versions are compatible with Berkeley DB. These notes assume that Tcl is 207installed as <b>d:\tcl</b>, but you can change that if you want.</p> 208<p>The Tcl library must be built as the same build type as the Berkeley DB 209library (both Release or both Debug). We found that the binary 210release of Tcl can be used with the Release configuration of Berkeley DB, 211but you will need to build Tcl from sources for the Debug 212configuration. Before building Tcl, you will need to modify its 213makefile to make sure that you are building a debug version, including 214thread support. This is because the set of DLLs linked into the Tcl 215executable must match the corresponding set of DLLs used by Berkeley DB.</p> 216<h4>Building Tcl with Visual C++ .NET or above</h4> 217<ol> 218<p><li>Set the include directories. Choose <i>Tools -> Options 219-> Projects -> VC++ Directories</i>. Under the "Show 220directories for" pull-down, select "Include files". Add the full 221pathname for <b>d:\tcl\include</b>, then click OK. This is the 222directory that contains <b>tcl.h</b>. 223<p><li>Set the library files directory. Choose <i>Tools -> 224Options -> Projects -> VC++ Directories</i>. Under the "Show 225directories for" pull-down, select "Library files". Add the full 226pathname for the <b>d:\tcl\lib</b> directory, then click OK. This is 227the directory needed to find 228<b>tcl84g.lib</b> (or whatever the 229library is named in your distribution). 230<p><li>Set the build type to Release or Debug in the drop-down on the .NET 231tool bar. 232<p><li>To build, right-click on db_tcl and select Build. This builds the Tcl 233support library for Berkeley DB, placing the result into 234<b>build_windows\Debug\libdb_tcl47d.dll</b> or 235<b>build_windows\Release\libdb_tcl47.dll</b>. 236</ol> 237<p>If you use a version different from Tcl 8.4.x you will 238need to change the name of the Tcl library used in the build (for 239example, <b>tcl84g.lib</b>) to the 240appropriate name. To do this, right click on <i>db_tcl</i>, go to 241<i>Properties -> Linker -> Input -> Additional 242dependencies</i> and change 243<b>tcl84g.lib</b> to match the Tcl 244version you are using.</p> 245<h4>Building Tcl with Visual C++ 6.0</h4> 246<ol> 247<p><li>Set the include directories. Choose <i>Tools -> Options 248-> Directories</i>. Under the "Show directories for" pull-down, 249select "Include files". Add the full pathname for 250<b>d:\tcl\include</b>, then click OK. This is the directory that 251contains <b>tcl.h</b>. 252<p><li>Set the library files directory. Choose <i>Tools -> 253Options -> Directories</i>. Under the "Show directories for" 254pull-down, select "Library files". Add the full pathname for the 255<b>d:\tcl\lib</b> directory, then click OK. This is the directory 256needed to find <b>tcl84g.lib</b> (or 257whatever the library is named in your distribution). 258<p><li>Go to <i>Build -> Set Active Configuration</i> and select 259either the Debug or Release version of the db_tcl project. Then press 260OK. 261<p><li>To build, select <i>Build -> Build 262libdb_tcl47.dll</i>. This builds the Tcl support 263library for Berkeley DB, placing the result into 264<b>build_windows\Debug\libdb_tcl47d.dll</b> or 265<b>build_windows\Release\libdb_tcl47.dll</b>. 266</ol> 267<p>If you use a version different from Tcl 8.4.x you will 268need to change the name of the Tcl library used in the build (for 269example, <b>tcl84g.lib</b>) to the 270appropriate name. To do this, choose 271<i>Project -> Settings -> db_tcl</i> 272and change the Tcl library listed in the Object/Library modules 273<b>tcl84g.lib</b> to match the Tcl version 274you are using.</p> 275<b>Distributing DLLs</b> 276<p>When distributing applications linked against the DLL (not static) 277version of the library, the DLL files you need will be found in the 278<b>build_windows\Release</b> subdirectory, or 279<b>build_windows\Debug</b> if you distribute a debug version. You may 280also need to redistribute DLL files needed for the compiler's runtime. 281For Visual C++ 6.0, these files are <b>msvcrt.dll</b> and 282<b>msvcp60.dll</b> if you built with a Release configuration, or 283<b>msvcrtd.dll</b> and <b>msvcp60d.dll</b> if you are using a 284Debug configuration. Generally, these runtime DLL files can be 285installed in the same directory that will contain your installed Berkeley DB 286DLLs. This directory may need to be added to your System PATH 287environment variable. Check your compiler's license and documentation 288for specifics on redistributing runtime DLLs.</p> 289<table width="100%"><tr><td><br></td><td align=right><a href="../build_unix/ultrix.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../build_win/small.html"><img src="../../images/next.gif" alt="Next"></a> 290</td></tr></table> 291<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 292</body> 293</html> 294