The DEX C++ interface contains include files and dynamic libraries in order to compile and run an application using DEX. The general procedure is to first add the include directories to your project, then link with the supplied libraries corresponding to your operating system and finally copy them to any place where they can be loaded at runtime (common places are the same folder as the target executable file or your system libraries folder).
Let's have a look at a more detailed description of this procedure in the most common environments.
Remember that the package should already be unpacked in a known directory (see chapter 2).
If your development environment is Microsoft Visual Studio, your first step should be to add to the
Additional include directories, C++ general property of your project and dex subdirectory of the includes-folder from the DEX package.
This must also be done with the library directory, so the
Additonal library directories linker general property must be edited to add the correct subdirectory of the DEX lib folder for your operating system.
After this, you should add the dex ".lib" library to the
Additional Dependencies linker input property.
Finally make sure that the dll files can be found at run time. An easy way to do this is to add a post-process in your project to copy the dll files to the same output folder where your application executable will be built.
An alternative would be to simply put all the native ".dll" files into your Windows system folder (
SysWOW64 depending on your Windows version).
Now you are ready to build and run the application like any Visual Studio project.
Finally, if you just want to quickly test the HelloDEX sample application, you can use the command line. First setup your compiler environment with the
vsvars32.bat file if you are using a 32-bit MS Visual Studio.
> call "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat"
or with the
vcvarsall.bat file if you are using a 64-bit MS Visual Studio.
> call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64
Then compile and run the application (example on a 32-bit Windows):
> cl /I"path_to_the_unpacked_dex\includes\dex" /D "WIN32" /D "_UNICODE" /D "UNICODE" /EHsc /MD /c HelloDex.cpp > link /OUT:"HelloDex.exe" HelloDex.obj /LIBPATH:"path_to_the_unpacked_dex\lib\windows32" "dex.lib" > xcopy /y "path_to_the_unpacked_dex\lib\windows32\*.dll" . > HelloDex.exe
In this guide we are not going to focus on any specific integrated development environment for Linux or Mac OS because it is beyond the scope of the guide. Instead we will give an explanation of the procedure which you can adapt to the specifics of your development environment.
In the includes directory, there is the subdirectory dex that must be added as include search directory in your project.
The lib directory contains a subdirectory for each operating system available. You should add the correct directory for your computer as a link search directory in your project.
To link your application, the dex and your pthread libraries must be used in this order.
Finally you may need to add the directory where the libraries can be found to the LD_LIBRARY_PATH environment variable to be sure that they will be found at runtime.
Finally, if you just want to quickly test the HelloDEX sample application, you can use the command line.
$ g++ -I/path_to_the_unpacked_dex/includes/dex -o HelloDex.o -c HelloDex.cpp $ g++ HelloDex.o -o HelloDex -L../lib/linux64 -ldex -lpthread $ export LD_LIBRARY_PATH=/path_to_the_unpacked_dex/lib/linux64/ $ ./HelloDex