Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - C and C++ Programming » Tutorial: Build an Application Using ODBC

Introduction to UltraLite ODBC Next Page

Lesson 1: Getting started

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.

Create and test your build environment
  1. 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= \
    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.

  2. 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.

  3. 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.