• Examples (iOS)
• Examples (Java/Android)
• Examples (C++)
Server API Documentation

 

» Client API setup | C++

» macOS — Xcode 7 and higher

» Libraries compilation

To compile the required libraries, please check that you are using at least the release 1.59 of Boost.

Launch a Terminal on the file system path [api_folder]/Core/BoostAsio/Unix and type in the command chmod -R a+rwx+X ./

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 the built libraries.

The Terminal can now be closed.

Start Xcode and create an OS X Dynamic Library project for STL C++

Add all SmartFox API folders and files to the created project.



Now remove the Core/BoostAsio, Core/OpenSSL and ZLib references from the project (NOTE: just remove the references, do not the delete the actual folders)


This is what the project view should look like after having removed the three items in the previous step:

Under Build Settings:

 

NOTE: the position of the openssl library depends on the package manager used to install on your Mac. You can use Brew or MacPorts to setup the latest OpenSSL libraries. Then make sure to reference the correct path based on the location used by the tool of your choice.

Alternatively you can download the OpenSSL sources from the official website and compile it.
Firstly decompress the archive, open a terminal in the unpacked folder and type:

  • sudo mkdir -p /usr/local/openssl-1.0.2k
  • ./Configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.2k
  • make
  • sudo make install

Add the following paths to the Prelink libraries menu

Set Perform Single-Object Prelink to Yes.
Set Other Linker Flags to -lz.

You can now build the SmartFoxServer 2X API and use it in your project.

» Setting up an SFS2X project

Move to the project settings of your Xcode client application. Select the topmost node from the Project Navigatorand select Build Settings.

Under Header Search Path add:

Under Library Search Path add:

where [Compiled-API-Folder] is the path where you have stored the static API library file.

Under Other Linker Flags add -lz

Finally click on Build Phases in the top bar, select Link Binary with Libraries and add the API compiled .a file.

 

« back to main C++ API section