The Sparksee C++ interface contains include files and dynamic libraries in order to compile and run an application using Sparksee. 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 the sparksee subdirectory of the includes-folder from the Sparksee 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 Sparksee lib folder for your operating system.
After this, you should add the sparksee ".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).
It's important to check that the build platform selected matches the libraries that you are using.
Now you are ready to build and run the application like any Visual Studio project.
Finally, if you just want to quickly test the HelloSparksee sample application, you can use the command line. First setup your compiler environment with the
vsvars32.bat file (or
vcvarsall.bat) if you are using a 32-bit MS Visual Studio.
> call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
or with the
vcvarsall.bat file with the appropiate argument if you are using a 64-bit MS Visual Studio.
> call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64
Then compile and run the application (example on a 32-bit Windows):
> cl /I"path_to_the_unpacked_sparksee\includes\sparksee" /D "WIN32" /D "_UNICODE" /D "UNICODE" /EHsc /MD /c HelloSparksee.cpp > link /OUT:"HelloSparksee.exe" HelloSparksee.obj /LIBPATH:"path_to_the_unpacked_sparksee\lib\windows32" "sparksee.lib" > xcopy /y "path_to_the_unpacked_sparksee\lib\windows32\*.dll" . > HelloSparksee.exe
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 a list of procedures which you can adapt for the specifics of your development environment.
In the includes directory, there is the subdirectory sparksee 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 sparksee 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, or DYLD_LIBRARY_PATH in MacOS, environment variable to be sure that they will be found at runtime.
Finally, if you just want to quickly test the HelloSparksee sample application, you can use the command line.
$ g++ -I/path_to_the_unpacked_sparksee/includes/sparksee -o HelloSparksee.o -c HelloSparksee.cpp $ g++ HelloSparksee.o -o HelloSparksee -L../lib/linux64 -lsparksee -lpthread $ export LD_LIBRARY_PATH=/path_to_the_unpacked_sparksee/lib/linux64/ $ ./HelloSparksee
The Android usage is not very different from the Linux usage.
You also have to add the includes/sparksee directory to the includes search path.
The sparksee dynamic library and the provided stlport_shared library must be included in the applicacion. There are 4 versions of each library in subdirectories from the lib/ directory. You must use the appropiate libraries for the processor target of your project.
The stlport_shared is the NDK library but must be included in the application instead of just being linked.
The z and dl libraries from the Android NDK must be linked too.
Once you have extracted the Sparksee.framework directory from the distribution ".dmg" file, the basic steps to use Sparksee in your Xcode application project are the following:
Add the Sparksee include files to the search path in your application project: The path to
Sparksee.framework/Resources/sparksee/ must be added as non-recursive to the
User Header Search Paths option on the build settings of your xcode application project. This is required because Sparksee include files use a hierarchy of directories not usual in an xcode framework. Therefore, they can't be included in the regular Headers directory of the framework.
Add the Sparksee.framework to the
Link Binary With Libraries build phase of your application project. You can just drag it there.
Choose the appropiate library:
libstdc++ (GNU C++ standard library) or
libc++ (LLVM C++ standard library with C++11 support) in the
C++ Standard Library option in the build settings of the compiler. The option choosen must match the downloaded version of the Sparkseecpp for iOS.
Remember that all the source files using C++ should have the extension ".mm" instead of ".m".
Take into account that, after all these changes, a
Clean of your
Project may be needed.
Setting an explicit memory limit to the Sparksee cache (using the SparkseeConfig class) is highly recommended. For more information about SPARKSEE cache and the SPARKSEEConfig class check the full User Manual and the reference guides.