
Compilation using generic build tools.
Maybe there are programmers which need absolute freedom in using build tools,
for example because they already created their own large projects, maybe
based on Jam or BoostBuild or other exotic build systems. In these case,
they cannot embed Chrono::Engine using the ChronoEngineWizard for Visual Studio,
nor they can use our makefile system.
Therefore, this section explains which are the low-level settings for
using the Chrono::Engine library into a generic C++ project. This topic
may look complex, but if you already have experience in linking some
other library, you know that it is simply a matter of keeping the
compiler and the linker informed about includes, libs and symbols.
Either that you are using IDEs like Code::Blocks, or you are using
Jam or CMake or other build tools, it is up to you to configure the
following settings in your system; here there is only the list.
1.c - Compiler includes
Projects based on Chrono::Engine must access the .h headers of the library.
YOur C++ compiler must know this. The include directory is
[path to Chrono::Engine]/source
For example, if you installed in C:\, the Microsoft C++ compiler will take the following
flag in the command line:
/I "C:\ChronoEngine\source" .
Another setting about includes is for the Irrlicht library, if you want to
use it for visualization (as in demos). For Irrlicht, the include directory is
[path to Irrlicht]/include
For example, if you installed Irrlicht in C:\, the Microsoft C++ compiler will take the flag
/I "C:\irrlicht-1.3.1\include"
2.c - Compiler flags and symbols
The compiler requires the following symbols to be defined:
WIN32
_CRT_SECURE_NO_DEPRECATE (optional)
For example, with the Microsoft C++ compiler, you will use these
flags in the command line:
/D "WIN32" /D "_CRT_SECURE_NO_DEPRECATE" .
Also, note that in case of Microsoft compiler, you also need to
use the flag
/MDd
(use debug dlls) when in debug mode, to avoid problems at dynamic linking and
consequent random crashes.
Note: only if you are using the MingW GNU compiler, you may need to add the
following flags to the linker options, otherwise in some cases you may get
problems at linking stage:
-Wl,--enable-runtime-pseudo-reloc
For example, using the Code::Blocks IDE, go to the menu Build/Compiler Options,
go to "Linker" tab, and insert the previous flags in the "Other linker options" field.
3.c - Linker libraries
The linker needs to know that it must link the Chrono::Engine library: it requires
its name and where to find that library.
Note Chrono::Engine ships with two libraries per each compiler:
the full-speed release library and the debug library - the latter ends with ...DBG.lib,
for example ChronoEngine.lib and ChronoEngineDBG.lib. If you compile your code in debug
mode, you must link the DBG library.
The following are the libraries to link:
ChronoEngine.lib ( or ChronoEngineDBG.lib if in debug mode!),
irrlicht.lib (only if you areusing Irrlicht for visualization).
Also, the compiler must know where to find these libraries (the '/LIBPATH' flag
in Microsoft linker, for instance). In Chrono::Engine,
the directory of the .lib depends on the type of the compiler you want to use.
For example, if using Visual C++, the directory is
[path to Chrono::Engine]\lib\Win32_VisualStudio
For Irrlicht, it will be
[path to Irrlicht]\lib\Win32-VisualStudio
Similar paths are for the MingW GNU compiler, etc.
For example, with the Microsoft C++ linker, the following is an example of
command line options for linking a small example called 'Project6':
/OUT:"C:\Programmi\ChronoEngine3\bin\Win32_VisualStudio\Project6.exe"
/LIBPATH:"C:\Programmi\ChronoEngine3\lib\Win32_VisualStudio"
/LIBPATH:"C:\engine_demo\irrlicht-1.3.1\lib\Win32-visualstudio"
/MANIFEST /MANIFESTFILE:"Release\Project6.exe.intermediate.manifest"
/ERRORREPORT:PROMPT ChronoEngine.lib irrlicht.lib kernel32.lib
4.c Executables and DLLs
After compilation, you usually get an .exe file of your project. That executable must find the
Chrono::Engine dll (dynamic link library) as soon as it is launched, otherwise it gives an
error.
There are different methods to let the executable 'find' the DLLs, the simpliest
is to put these DLL into the same directory of the executable.
The libraries which must follow the executable are:
ChronoEngine.dll
js32.dll
Irrlicht.dll (only if you are using Irrlicht for visualization).
These two libraries can be found in the
directory [path to Chrono::Engine]\bin\Win32_VisualStudio. Just copy and paste them
in the directory where you have your .exe file.
Another option, is to add the [path to Chrono::Engine]\bin\Win32_VisualStudio
directory to your PATH environment variable.
The examples above apply also for the MingW compiler, but instead of ..\Win32_VisualStudio
please read ..\Win32_gcc
Back to the installation guide