Building programs that link with liblept
It’s simple to make projects that link with liblept since you can
just use the standard Visual Studio wizards. Most of the compiler and linker setting will be
dictated by your application’s needs; you only have to add where to find
the header files and libraries needed with liblept and which
libraries you want to link with.
First open up your project’s Property Pages (right-click the
project then choose from the context
menu). Change Configuration: to All
Configurations. You then have to set three items:
Set Configuration Properties | C/C++ | General | Inherited
Property Sheets to:
This lets you use the *_VERSION user macros when specifying the
libraries you want to link with. See this section for more information on this
Property Sheet and “user macros”.
To Configuration Properties | C/C++ | General | Additional
Include Directories add:
To Configuration Properties | Linker | General |
Additional Library Directories add:
Of course, if you’ve used some other location/name instead of
C:\BuildFolder for where the vs2008, include and lib
directories reside, then use that instead.
Alternatively, if you don’t mind having all programs use these
header files and libraries, you could also globally change where Visual
Studio 2008 looks for include files and libraries by setting
| Project and
Settings | VC++ Directories.
The last step is setting Configuration Properties | Linker |
Input | Additional Dependencies. To link with the dynamic library
Release version of liblept add this:
To link with the dynamic library Debug version of liblept add this:
To link with the static Release version of liblept add these:
To link with the static Debug version of liblept add these:
You can also use create_unnumbered_hardlinks.bat to make simplified
versions of the library filenames via NTFS hardlinks and link with those
instead. See here for more details.
Any .c files that use Leptonica functions have to include
allheaders.h. If you want to use the Windows-only
pixGetWindowsHBITMAP(PIX *pixs) to convert a Leptonica PIX to
a Windows HBITMAP you also have to include leptwin.h. It’s not
automatically included by allheaders.h.
Create a \tmp directory
Create a \tmp directory on the same drive from which you will be
running your liblept based programs. Some parts of liblept assume
they can write to /tmp and will mysteriously fail if this directory
This issue has been addressed starting with liblept168, but it’s
still a good idea for now to have a \tmp directory.
Leptonica should now write all temporary files to your temp
directory. This is normally C:\Documents and
Settings\<username>\Local Settings\Temp but can be changed by
setting the TEMP and TMP environment variables.
Intellisense and liblept
Intellisense is a great Visual Studio feature that automatically
completes function names, shows function arguments, quickly lets you go
to a function’s definition, etc. There seems to be a problem, however,
with navigating to liblept function definitions. When you right
click a function name that is part of the liblept library and choose
(or press the F12 key),
instead of jumping to the definition it shows you the declaration in
Adding the location of leptonica-1.68\src to
| Projects and Solutions
| VC++ Directories | Show Directories For | Source Files doesn’t help,
even though that list is described as “Path to use when searching for
source files to use for Intellisense.”
(The commercial program Visual Assist X for Visual Studio has the command
does do the correct thing as long as you follow these instructions.)
In order to have Visual Studio’s
command work correctly with liblept, you have to add its project to
your current solution:
Right click your solution in the Solution Explorer, and choose
from the context menu.
Select the leptonica-1.68\vs2008\leptonica.vcproj
file and click Open.