Step 6
We are now ready to start building all the projects. Go to the folder, "G:\dev\src\icu\source\allinone" and double click on "allinone.sln", this will launch Visual Studio and open the ICU solution that contains all the projects. From the "Solution Explorer" tab, click select the project named, "common" and right click on it and select, "Properties".
From the Properties dialog box, click on "General" from the treeview on the right pane and type in, "$(SolutionDir)" for the "Output Dir" field.
Next go down to the "Linker" section and select "General", modify the "Output File" field to use "$(BuildDir)\bin\" as the output location. Make sure not to alter the DLL name.
Finally select the "Advanced" tree item found under "Linker" and modify the, "Import Lib" filed to use, "$(BuildDir)\lib\" as the output location. Make sure not to alter the Lib name.
Now you will need to do the same steps for project "i18n".
Note: Make sure to modify both "Debug" and "Release" project settings!
Now build project, "i18n" and this will causes the dependent projects, "common" and, "stubdata" to also get built. Once the projects are built you should have 2 DLL files and 2 Lib files in their respect folders. These files will be used to the build SQLite3 DLL.
Note: for those using VC++ Express, you will also need to manually include the link to advapi32.lib in your project setting under the linker section.
Let's now take a look at creating the SQLite3 project...
Step 7
Now we need to create an empty project to build the SQLite DLL.
From Visual Studio create a new Win32 project called sqlite3.
For the location, enter "G:\dev\src"
This will cause the solution and project files to be saved under the sqlite3 source code director.
Click on the "Next" button and make sure to check the "Empty Project" options and set the "Application Type" to DLL. Once you do this click on the "Finish" button.
After the SQLite3 project had been generated, right click on the project name and select "Add -> New Items". When the Files dialog opens, make sure to select all the sqlite3 source and header files as will as the sqlite3.def file and click on OK.
Now we will need to remove the folowing source files from the SQLite3 project:
- mutex_os2.c
- mutex_unix.c
- os_os2.c
- os_unix.c
- shell.c
- tclsqlite.c
NOTE: In order to build a command line shell of Sqlite, you would need to include the file, "shell.c" in your project and also make sure the project was set to build an exe and not a dll binary.
Now we are ready to set the project settings...
Step 8
The project setting for sqlite3 must now be set, go to the solution tab and right click on the "sqlite3" project an select properties. When the properties dialog appears, select, "All Configuration" from the "Configuration" selection list at the top right.
Now from the treeview pane on the right, select "General" from "Configuration Properties" and type, "$(SolutionDir)" in the, "Output Dir" field.
Now we need to setup the Include path for the ICU files. From the treeview select, "General" from the "C/C++" section and type in, "$(SQLite3_Project)\icu\include" for the directory path under, "Additional Include Dir" field.
We now move down to the "Linker" section and select "General" from the treeview pane.
First modify the "Output File" so it is, "$(BuildDir)\bin\$(ProjectName).dll"
Next this is optional, but I like to disable 'Incremental Linking" by setting it to "NO".
Finally we need to set the Lib path so the linker can find all the ICU Libs files.
To do this set, "Additional Library Dir" to be, "$(BuildDir)\lib"
We are almost done! We need to set the ICU Lib files that need to be linked to, there are 3 files:
- icudt.lib
- icuuc.lib
- icuin.lib
Enter these names into the, "Additional Dependencies" field.
Then type in, "sqlite3.def" into the "Module Definition File" field. This is required to exports the SQLite3 APIs from the DLL.
Now the only thing left to do is specify the SQLite Lib file. Select "Advance" from the Linker section and type in, "$(BuildDir)\lib\$(TargetName).lib" into the "Import Lib" field.
We can finally build the SQLite3 DLL! =)
Static Linking and SQLite
If you followed the above step, the way the project is set to build, you will end up with several DLLs. If you are like me you don't want to be dragging around those DLLs to whatever project that is going to use the SQLite database engine. So there are a few things you can do to alleviate this.
For static linking with ICU, the following is suggested by George Rhoten (ICU Developer).
"You should instead be using the Cygwin/MSVC build configuration ( http://source.icu-project.org/repos/icu/icu/tags/release-3-8-1/readme.html#HowToBuildCygwin ). Building static libraries on Windows with the project files is non-trivial, which is why the Cygwin/MSVC build configuration is available. The Cygwin/MSVC build configuration is also available in case you want to build ICU on 64-bit Windows, or you want to tweak the ICU build in any other common way."
You can also change the SQLite DLL project to build a static library, so your personal project will not require a SQLite DLL. However if you have several project that will be using the SQLite engine, then it make sense to leave the SQLite project as-is to build a DLL file that can be shared amongst the projects.