In this tutorial, you create a set of files, including source files and executable files. You should make a directory to hold these files. In the remainder of the tutorial, it is assumed the directory is c:\tutorial\ulodbc. If you choose a different name, use that name throughout.
The ODBC interface does not depend on any particular C/C++ compiler or development environment. The tutorial uses a makefile with Microsoft's nmake syntax. If you are using a different development environment, make the appropriate substitutions.
Add the following code to a file called makefile in your tutorial directory:
IncludeFolders= /I"$(SQLANY10)\h" CompileOptions=/c /nologo /W3 /Od /Zi /DWIN32 /DUL_USE_DLL LibraryFolders= \ /LIBPATH:"$(SQLANY10)\ultralite\win32\386\lib" Libraries= ulimp.lib LinkOptions=/NOLOGO /DEBUG sample.exe: sample.obj link $(LinkOptions) sample.obj $(LibraryFolders) $(Libraries) sample.obj: sample.cpp cl $(CompileOptions) $(IncludeFolders) sample.cpp
These options compile a source file called sample.cpp into an executable sample.exe, using the UltraLite import library for Windows (ulimp.lib). They rely on the environment variable SQLANY10, which is defined as your SQL Anywhere installation directory. See SQL Anywhere Environment Variables.
Add the following code to a file called sample.cpp in your tutorial directory:
#include "ulodbc.h" #include <stdio.h> #include <tchar.h> int main() { return 0; }
This application simply returns 0 to the calling environment.
Compile and link sample.cpp.
If you are using the Microsoft compiler, type nmake at a command prompt to compile and link your application. Otherwise, use the appropriate command for your development environment.
Compiling and linking the application confirms that your build environment is set up properly. You are now ready for the rest of the tutorial.