how to use smart fox c++ for iOS/OSX ?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

777666
Posts: 21
Joined: 17 Apr 2015, 02:58

how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 31 Oct 2015, 16:29

anyone know how to create mac OS X or iOS projects use smart fox c++ ?
it seems like these c++ headers are not working for mac projects. (both windows and unix)
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 01 Nov 2015, 11:43

on one ever tried ?

what I am trying to do is to use a c++ engine to write cross platform games, so I need sfs2x c++ for both windows and mac side.
c++ example don't have a mac integrated solution. anyone have ever tried c++ for osx ?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: how to use smart fox c++ for iOS/OSX ?

Postby Lapo » 02 Nov 2015, 10:44

The process for compiling the C++ API in OSX is very similar to that for Linux.
http://docs2x.smartfoxserver.com/Gettin ... clipse-nix

Have you followed those steps?
If so, can you tell us exactly what is not working for you?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 02 Nov 2015, 18:19

I am getting error at building qt projects under core/boostasio/unix/tools/build/v2/test/qt5/
for example #include <QtWidgets/QApplication>

here is what i did for OS X project, please let me know if anything was wrong
1: create OS X project -> framework & library -> library with option of framework = stl c++ lib, type = dynamic
2: after i crated project, copy all files to <project dir>/SmartFoxClientApi/
3: execute ./bootstrap.sh –prefix=boost/ and ./b2 under <project dir>/SmartFoxClientApi/Core/BoostAsio/Unix
4: drag recently copied files to Xcode project
5: right click to removed references from Deploy, Core/BoostAsio/Windows, Core/OpenSSL/Win32, Core/OpenSSL/Win64, all sub folders under ZLib
6: add SMARTFOXCLIENTAPI_EXPORTS, BOOST_THREAD_PROVIDES_FUTURE to Preprocessor
7: add Core/BoostAsio/Unix, Core/OpenSSL/Unix/include to User header search path
8: add Core/BoostAsio/Unix/stage/lib, Core/OpenSSL/Unix/Lib/x86_64-linux-gnu, /usr/lib/ssl to Library search path
9: add boost_thread, boost_system, ssl, crypto to Prelink Libraries

please let me know if anything need to be adjusted.

thanks
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 04 Nov 2015, 04:42

no one ever had it working before ?
any help please!!!
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: how to use smart fox c++ for iOS/OSX ?

Postby Lapo » 04 Nov 2015, 08:26

I have passed your request to our C++ experts. Stay tuned.
Lapo

--

gotoAndPlay()

...addicted to flash games
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 04 Nov 2015, 10:59

thank you.
by the way, it would be nice if you guys can simply provide library files plus a group of header files, so people don't have to compile the source project anymore.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: how to use smart fox c++ for iOS/OSX ?

Postby Lapo » 04 Nov 2015, 11:02

777666 wrote:thank you.
by the way, it would be nice if you guys can simply provide library files plus a group of header files, so people don't have to compile the source project anymore.

We do that for all supported platforms with the exclusion of C++.
There are just too many combinations of target architectures and platforms that it would be impractical to keep up.
Lapo

--

gotoAndPlay()

...addicted to flash games
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 06 Nov 2015, 15:34

Lapo wrote:
777666 wrote:thank you.
by the way, it would be nice if you guys can simply provide library files plus a group of header files, so people don't have to compile the source project anymore.

We do that for all supported platforms with the exclusion of C++.
There are just too many combinations of target architectures and platforms that it would be impractical to keep up.


any news on what I need to do for Xcode settings ?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: how to use smart fox c++ for iOS/OSX ?

Postby Lapo » 06 Nov 2015, 15:52

Sorry, we run into a few problems.
Our C++ experts mainly work on Windows and Linux, so we're now setting up an OSX environment with XCode etc... and doing some basic test to see if we can reproduce the issue.

We'll give you update soon.
Lapo

--

gotoAndPlay()

...addicted to flash games
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 06 Nov 2015, 16:54

cool, keep me posted please.
my company is about to start a new project which will be mac supported, if smart fox is not Xcode c++ supported, we will be forced to choose a different server engine.

i believe many developers are using Xcode c++ developing games. it would be fantastic if smart fox team can provide a solution for Xcode c++.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: how to use smart fox c++ for iOS/OSX ?

Postby MBagnati » 10 Nov 2015, 23:31

Hi,

I have set an OSX Yosemite environment with XCode 7.
I have successfully built SmartFox C++ API, these the main steps:
  • Get API files from SmartFox website
  • Launch a Mac Terminal. Move to folder [api_folder]/Core/BoostAsio/Unix and run command chmod -R a+rwx+X ./
  • Update the Boost library contained into SmartFox API (rel. 1.55) to latest rel. 1.59. This step is required to solve a Boost library failure when compiled in OS X environment
  • Execute command ./bootstrap.sh -prefix=boost/ from Terminal and wait for its execution
    Then execute command ./b2
    At this point you should have Boost libraries in [api_folder]/Core/BoostAsio/Unix/stage/lib folder
  • Create a dynamic library STL C++ project by XCode 7
  • Add all SmartFox API folders and files to project
  • Leave only SmartFox API source files in Targets->Build Phases->Compile Sources
    Leave only SmartFox API header files in Targets->Build Phases->Headers
    Leave only Boost libraries in Targets->Build Phases->Link Binary With Libraries
  • Set "Processor Macros"
    SMARTFOXCLIENTAPI_EXPORTS
    BOOST_THREAD_PROVIDES_FUTURE
  • Disable the usage of precompiled headers
  • Set "Header Search Paths"
    [api_folder]/Core/BoostAsio/Unix
    /usr/local/Cellar/openssl/1.0.2a-1/include
  • Set "Library Search Paths"
    [api_folder]/Core/BoostAsio/Unix/stage/lib
    /usr/local/Cellar/openssl/1.0.2a-1/lib
  • Set "Prelink libraries"
    /usr/local/Cellar/openssl/1.0.2a-1/lib/libcrypto.a
    /usr/local/Cellar/openssl/1.0.2a-1/lib/libssl.a
  • Set "Perform Single-Object Prelink" to Yes
  • Set "Other Linker Flags" to -lz

...and now with a bit of luck we should be able to build the SmartFox API
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 22 Nov 2015, 10:23

I was able to build the library, but it failed to load at the project that uses the library.

here are some questions left:

Add all SmartFox API folders and files to project
Leave only SmartFox API source files in Targets->Build Phases->Compile Sources
Leave only SmartFox API header files in Targets->Build Phases->Headers
Leave only Boost libraries in Targets->Build Phases->Link Binary With Libraries

1:can you specific what need to be included ? I assume all windows folders will not be included and boost folder (Core/BoostAsio/Unix) shall only be included but not compiled ?
how many source files and header files do you have on targets->build phases->compile sources / headers ? at my case, without windows stuff, I only have 131 source files and 251 header files (with zlib as a standalone project created automatically by Xcode use /usr/bin/make)

2: what should i do to the ZLib ? from the screenshot I found from documentation site, http://docs2x.smartfoxserver.com/Gettin ... cpp-Xcode7
your ZLib appear as a group folder, but at my case, if I drag it into the project without use provided /usr/bin/make tool (which appear the same as a group folder like what you had on the screenshot) it will give me errors at building it.
if i use /usr/bin/make, which will create a Xcode project automatically, but it works.

3: anything special i need to do at projects uses smartfoxclientapi.dylib ? because once i have the dylib linked to my c++ project, it will fail the build at startup even without include / use any files from smart fox api project.
for the project use smartfoxclientapi.dylib, i included [api]/core/boostasio/unix/ and openssl path at header search path, and boost dylibs at library search path.
here is the error i got from starting an empty project uses smartfoxclientapi.dylib
(empty command line c++ project, all I did was included smartfoxclientapi.dylib targets->build phase->link binary with libraries, I have also tried to include [api]/core/boostasio/unix/ and openssl path at header search path, and boost dylibs at library search path. but it didn't work)
dyld: Library not loaded: libboost_atomic.dylib
Referenced from: /Users/user9928/Library/Developer/Xcode/DerivedData/UseDynamicLib-bsrtikjeypwllpafmzmqzmisiadh/Build/Products/Debug/libSmartFoxClientApi.dylib
Reason: image not found
Program ended with exit code: 9
777666
Posts: 21
Joined: 17 Apr 2015, 02:58

Re: how to use smart fox c++ for iOS/OSX ?

Postby 777666 » 24 Nov 2015, 22:30

any help please ?
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: how to use smart fox c++ for iOS/OSX ?

Postby MBagnati » 25 Nov 2015, 15:06

Hi,
I am not sure to have understood all points...I try to answer...

You say that you are able to build the library, so I assume that you have built the SmartFox API Library and problems regard only its usage in a consumer project.
In this scenario, I have not understood your notes
Add all SmartFox API folders and files to project
Leave only SmartFox API source files in Targets->Build Phases->Compile Sources
Leave only SmartFox API header files in Targets->Build Phases->Headers
Leave only Boost libraries in Targets->Build Phases->Link Binary With Libraries

These steps are described at http://docs2x.smartfoxserver.com/GettingStarted/client-api-cpp#cpp-Xcode7 and are instructions to build the SmartFox API Library!
They are not steps to build the API consumer application (where words "API consumer" means "the game based on SmartFox API")

In other words, your game will use SmartFox API library; SmartFox API uses Boost library.

Well, your first question is about which source files and headers must be included in "targets->build phases->compile sources / headers"
Here we are among the steps to build the SmartFox API Library; we have already built the BOOST Library and now we are setting the project to build the SmartFox API Library according with http://docs2x.smartfoxserver.com/Gettin ... cpp-Xcode7 instructions, are we?
In "targets->build phases->compile sources / headers" you should have all (and only) .cpp and .h files contained in SmartFox API folders
No BOOST or OpenSSL or ZLib source files because BOOST has been compiled previously and OpenSSL & ZLib do not not need to be compiled by our project.
Your numbers of one-two hundred of files sound good.

About ZLib, I think that you have not to build in SmartFox API project
In any case I do not see contraindications if you create a zlib project.

About the usage of smartfoxclientapi.dylib I suppose that error is caused by missed libraries.
As said above, smartfoxclientapi.dylib uses Boost libraries therefore when your game loads SmartFox API
the operating system will look for library dependences (boost_atomic, boost_system, boost_thread, boost_chrono, boost_date_time, boost_regex).
To solve the "library not loaded" error, try to copy these dylibs from the Boost folder where they have been built into folder where is your game application.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 49 guests