SFS2X Docs / GettingStarted / client-api-cpp-windows-eclipse
» Client API setup | C++
» Windows — Eclipse Cygwin
» Libraries compilation
To compile the required libraries you need Eclipse with C/C++ Development Tools and Cygwin installed on your computer.
Run Cygwin package installer to add SSL support. Installer is available at https://cygwin.com/install.html Execute setup-x86.exe or setup-x64.exe according with your operating system and use search feature to look for openssl and openssl-devel packages.
Add cygwin\bin to the system path and run Cygwin Terminal (see Windows Start\Programs menu).
In the Cygwin Terminal shell type the following command (use the proper path) to move to the [api_folder]\Core\BoostAsio\Unix folder.
> cd /cygdrive/c/.../[api_folder]/Core/BoostAsio/Unix
Now type in:
> ./bootstrap.sh –prefix=boost/
and wait for the command execution. When completed, type in:
> ./b2
If all has been done with success, you will find out that a new directory
named [api_folder]\Core\BoostAsio\Unix\stage\lib has been
created, containing five .dll files.
The Cygwin Terminal can now be closed.
» API compilation
Start Eclipse and choose File > New > Project from its menu. In the New Project wizard dialog, choose C++ Project from C/C++ section, than press Next.
In the C++ Project dialog:
- set a project name, for instance SmartFoxClientApi;
- remove the flag Use default location;
- browse the file system to set the folder [api_folder] as Location;
- select Empty Project from Shared Library section as Project type;
- select Cygwin GCC as Toolchains;
then press Finish.
Eclipse will create the SmartFoxServer2X C++ API project. Answer Yes when is asked to open the C/C++ perspective.
In the Project Explorer panel, perform the following exclusions (to do it, right-click on the project node and select Resource configuration > Exclude from build in the popup menu):
- exclude Deploy project node from the build for both Debug and Release configurations;
- exclude BoostAsio project node from the build for both Debug and Release configurations (located under the Core node);
- exclude OpenSSL project node from the build for both Debug and Release configurations (located under the Core node);
- exclude SmartFoxClientApi project node from the build for both Debug and Release configurations;
- Exclude all subfolders of Zlib project node from the build for both Debug and Release configurations.
Enter the Project settings panel and apply the following changes to C/C++ Build > Settings > Tool Settings:
- Set Position Independent Code flag under Cross GCC Compiler > Miscellaneous;
- Set Position Independent Code flag under Cross G++ Compiler > Miscellaneous;
- add __USE_W32_SOCKETS to the Defined symbols under Cygwin C++ Compiler > Preprocessor;
- add SMARTFOXCLIENTAPI_EXPORTS to the Defined symbols under Cygwin C++ Compiler > Preprocessor;
- add BOOST_THREAD_PROVIDES_FUTURE to the Defined symbols under Cross G++ Compiler > Preprocessor;
- add _WIN32_WINNT=0x0501 to the Defined symbols under Cygwin C++ Compiler > Preprocessor;
- browse the file system to include the path [api_folder]\Core\BoostAsio\Unix\ under Cygwin C++ Compiler > Includes;
- browse the file system to include the path [api_folder]/Core/OpenSSL/Unix/include/ under Cross G++ Compiler > Include paths;
- add ws2_32 under Cygwin C++ Linker > Libraries;
- add boost_thread under Cygwin C++ Linker > Libraries;
- add boost_system under Cygwin C++ Linker > Libraries;
- add libssl under Cross G++ Linker > Libraries;
- add libcrypto under Cross G++ Linker > Libraries;
- add libz under Cygwin C++ Linker > Libraries;
- set the library search path to [api_folder]\Core\BoostAsio\Unix\stage\lib.
- set the library search path to [api_folder]Core\OpenSSL\Unix\Lib\x86_64-linux-gnu.
Finally, select the menu item Project > Build project to perform a rebuild and generate the SmartFoxClientApi.dll library.
» Setting up an SFS2X project
This section applies only if you're using Eclipse as the iDE for your C++ application/game. If not, please check the documentation of your environment of choice on how to import external libraries.
In Eclipse, move to the project settings of your Eclipse client application. Select Preprocessor options under Cygwin C++ Compiler and add __USE_W32_SOCKETS to the Defined symbols for both Debug and Release configurations.
Now select Includes settings and add a reference to [api_folder]\Core\BoostAsio\Unix path, always for both Debug and Release configurations.
Finally move to the Libraries settings of Cygwin C++ Linker to add the [api_folder]\Core\BoostAsio\Unix\stage\lib path and the output directory where the previously compiled API was deployed. Also add ws2_32, boost_system andSmartFoxClientApi as application libraries. Perform these steps for both Debug and Release configurations.
You can now start using the SmartFoxServer 2X API in you project.