Notes for Windows users
Introduction
There are several important differences between Windows and POSIX operating systems that may effect the way you work.
- Using DLL instead of ELF shared objects
- Debug and Release versions for MSVC
Using DLLs
First of all I strongly recommend using CppCMS as DLL instead of static libraries:
- It allows you to use dynamic loadable views
- It allows you to switch CppCMS's dll version without recompiling the application, for example due to security update.
- It makes it easier to handle dependencies as for example you should not link manually with zlib, pcre and optional openssl or ICU.
Compilation
When you compile your program to use DLL you must add DLL_EXPORT
define at your project level. Such that the
code would be compiled with this define.
It should be defined for all source files including dynamically loadable views.
When you are using Visual C++ compiler make sure
you are using have "Enable C++ Exceptions" set /EHsc
command line argument.
cl /EHsc -DDLL_EXPORT app.cpp cppcms.lib booster.lib
Libraries naming convention
By default, both static libraries and DLL's with import libraries are built, they have following naming conversion:
GCC/MinGW:
libcppcms.dll
andlibbooster.dll
- the DLLslibcppcms.dll.a
andlibbooster.dll.a
- import library for the DLs.libcppcms.a
andlibbooster.a
- static libraries
MSVC:
Release versions
cppcms.dll
andbooster.dll
- the DLLscppcms.lib
andbooster.lib
- import library for the DLLs.libcppcms.lib
andlibbooster.lib
- static libraries
Debug versions
cppcms-d.dll
andbooster-d.dll
- the DLLscppcms-d.lib
andbooster-d.lib
- import library for the DLs.libcppcms-d.lib
andlibbooster-d.lib
- static libraries
Cygwin:
cygcppcms-1.dll
andcygbooster-0.dll
- the DLLslibcppcms.dll.a
andlibbooster.dll.a
- import library for the DLLs.libcppcms.a
andlibbooster.a
- static libraries
Make sure you:
- Do not mix static and import libraries
- Do not mix debug and release libraries when using Visual C++ compiler.
Building and using CppCMS under Visual Studio
Visual Studio is the only existing compiler that has incompatible debug and release runtime libraries and require separate compilation and linking of them.
So in order to build CppCMS correctly make sure
- You use nmake files CMake generator and do not use Visual Studio Projects
- You have all dependent libraries (icu, zlib, pcre, openssl) built with appropriate debug or release version.
- Run two independent compilations one for debug and one for release.
My personal recommendation is to create a set of debug and a set of release libraries in some location, let's say:
c:\apps\debug c:\apps\debug\include c:\apps\debug\lib c:\apps\debug\bin
With all debug versions of libraries like pcre, zlib and so on, for example c:\apps\debug\bin\pcred.dll
And the same for release:
c:\apps\release c:\apps\release\include c:\apps\release\lib c:\apps\release\bin
Such that the pcre.dll goes to c:\apps\release\bin\pcre.dll
And then run two separate builds:
For debug, open terminal and run:
cd z:\mybuilds\cppcms-1.0.1\ mkdir Debug cd Debug set PATH=c:\apps\debug\bin;%PATH% cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INCLUDE_PATH=c:/apps/debug/include -DCMAKE_LIBRARY_PATH=c:/apps/debug/lib -DCMAKE_INSTALL_PREFIX=c:/apps/debug .. nmake nmake test nmake install
Then do the same for release, open separate terminal and run:
cd z:\mybuilds\cppcms-1.0.1\ mkdir Release cd Release set PATH=c:\apps\release\bin;%PATH% cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INCLUDE_PATH=c:/apps/release/include -DCMAKE_LIBRARY_PATH=c:/apps/release/lib -DCMAKE_INSTALL_PREFIX=c:/apps/release .. nmake nmake test nmake install
This would make the life much simpler for you.
← Troubleshooting | Top | Hello World →