Hello, I just tried to put that on the Zeoslilb Wiki but for some odd reason it doesn't let me create a page. So - here is my current way to create freetds with libiconv support on Windows using Visual Studio:
How to build freetds with ICONV support:
This will also work for building freetds without ICONV support. Just skip everything that has to do with libiconv.
Step1: get and build libiconv:
libiconv is available from
http://savannah.gnu.org/projects/libiconv/. Download the latest version and extract it. I used Version 1.14. Go to the bugtracker. bug #35088 (Patch for native Visual Studio 2010 compilation) contains a patch to add Visual Studio 2010 project files. Download the patch and apply it to libiconv.
Step2: build libiconv:
Now open the project file <libiconvdir>\windows\VC10\iconv.vcxproj. Accept the suggestion of Visual Studio to Upgrade to a newer project version. Set the Solution Configuration to Release and the Platform to Win32 at the top of the IDE. Now select the iconv project in the Solution Explorer. Build it by either clicking Build -> Build iconv.
You will get some files in the folder <libiconvdir>\windows\VC10\Release
Step3: Get CMake
FreeTDS suggests to use CMake for building with Microsoft Visual Studio. Cmake will be used to generate the project files for use with Visual Studio. Download it from
https://cmake.org/download/ and install it.
Step4: Get Perl
Download ActivePerl from
http://www.activestate.com/activeperl and install it. CMake will need it later on.
Step5: Download FreeTDS
FreeTDS can be downloaded from
www.freetds.org. The version I downloaded had some issues that prevented me from generating the project files with CMake. So I downloaded the latest revision of the 0.95 branch from Github:
https://github.com/FreeTDS/freetds/tree/Branch-0_95. Extract your download.
Step6: Modify CMakeLists.txt
In your FreeTDS source directory there is a file called CMakeLists.txt. Open it in the texteditor of your choice. Find the part that starts with the following lines:
if(WIN32)
config_write("/* Define to 1 if you want to use SSPI for Win32 */\n#define HAVE_SSPI 1\n\n")
config_write("/* define to format string used for 64bit integers */\n#define TDS_I64_PREFIX \"I64\"\n\n")
config_write("/* Define to 1 if you have the SQLGetPrivateProfileString function. */\n#define HAVE_SQLGETPRIVATEPROFILESTRING 1\n\n")
After these lines insert the following lines:
config_write("
// iconv
#define HAVE_ICONV 1
#define ICONV_CONST
")
These lines will make sure libiconv gets used during the build process in Visual Studio. It seems that the current CMakeLists.txt just assumes that libiconv is not available on Windows and is always available on other systems.
Step7: Generate the Configuration files:
Create a directory where you want the Visual Studio project files to go and the build process to happen. This directory should not be in the FreeTDS source tree.
1) Open up cmake-gui.
2) Put the directory for your sourcecode in the field "Where is the source code". cmakegui will replace the backslashes with forward slashes. This is normal behaviour.
3) Put the newly created build directory in the field "Where to build the binaries:" Again cmakegui will replace the backslashes with forward slashes.
4) Press the configure Button. You will be presented with a lot of IDEs and build environments. Choose your Version of Visual Studio, keep the selection "Use default native compilers" and press finish.
5) Wait for CMake to finish the configuration.
6) Press the Generate button. CMake will now generate the project files for you.
7) Close cmake-gui.
Step 8: Modify the FreeTDS projects
CMake has generated the file ALL_BUILD.vcxproj in your <freetdsbuilddir>. Open it with Visual Studio. Wait for Visual Studio to load the Solution and all its subprojects. Some of the projects need to be modified because they now contain references to iconv.lib and iconv.h and Visual Studio doesn't know how to satify them.
In the solution explorer select the project in question and select Properties in the right clieck menu. The properties window will open.
For projects that require you to modify their Visual C++ Directories, select Configuration Properties -> VC++ Directories on the left hand pane. Now add <libiconvdir>\include to the Include Directories property.
For projects that require you to modify their linker settings select Configuration Properties -> Linker -> General. Add the directory <libiconvdir>\windows\VC10\Release to the Additional Library Directories property. Then select Configuration Properties -> Linker -> Input and add iconv.lib to the Additional Dependencies property.
After finishing these modifications, click ok to activate the changes and close the Property Pages window.
The following projects need to be modified:
tds: Visual C++ Directories
sybdb: Visual C++ Directories and linker settings
tdsodbc: Visual C++ Directories and linker settings
db-lib: Visual C++ Directories
tsql: Visual C++ Directories and linker settings
ct: linker settings
now right-click on the ALL_BUILD project and build it.
Note: if you only want to build the freetds dll it just might be enough to build the sybdb project. In that case modifying the tds project and the sybdb project might just be enough.
If the build succeeds, you will find the sybdb.dll in the directory <freetdsbuilddir>\src\dblib\Release
Congatulations - you now hav e working freetds dblib.