Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any process to build this. #1

Closed
pulkitnandan opened this issue Oct 20, 2016 · 5 comments
Closed

Any process to build this. #1

pulkitnandan opened this issue Oct 20, 2016 · 5 comments
Assignees

Comments

@pulkitnandan
Copy link

I have failing to let cmake find boost libraries and pthread libs and headers, is this project working, does it's setup require more information. As after following standard process to setup this project, I'm failing and have lost atleat 20 hours.

@alvarofcgm
Copy link

Hi pulkitnandan,

I suppose you are using CMake with Linux or MacOS

This is what I recommend:

1- First build a Microsoft C++ REST SDK (Casablanca) project:
(follow https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Linux)

Install all the needed build tools and libraries:

sudo apt-get install g++ git make libboost-all-dev libssl-dev cmake

clone casablanca repository:

git clone https://github.com/Microsoft/cpprestsdk.git casablanca

build the project:

cd casablanca/Release
cmake .
make

Now test that for example BlackJack example works executing:

casablanca/Release/Binaries/blackjackserver

and typing in your browser the URL:
http://localhost:34568/blackjack/dealer

If you can see a json, great! it works fine and you can continue, if something went wrong you have to make this step work before continuing.

you may have more information about this first step here: https://github.com/Microsoft/cpprestsdk/wiki

2 - Integrating granada to C++ REST SDK:
In the granada project you can find a Release folder. This Release folder contains an include folder, an src folder and a samples folder (like in your already built C++ REST SDK project!) inside each one you will find a granada folder. You need to link or put these granada folders respectively in the include, the src and the samples folder of your C++ REST SDK project.

so you now should have:
casablanca/Release/include/granada
casablanca/Release/src/granada
casablanca/Release/samples/granada

In each of these folders you should have other folders and files. And in samples/granada a CMakeLists.txt file.

I recommend your casablanca/Release/samples/granada/CMakeLists.txt look like this for the moment:

set(GRANADA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/granada")
add_subdirectory(sessions-get-and-post)
#add_subdirectory(sessions-login-and-cart)
#add_subdirectory(oauth2-server)
#add_subdirectory(plugin-server)

(I have commented 3 of the 4 examples, so you first build the project with only one and easy example that does not require ANY extra libraries to work)

After that, include this line in the bottom of the casablanca/Release/CMakeLists.txt:

add_subdirectory(samples/granada)

These CMakeLIsts file should look to something like this: https://github.com/webappsdk/granada/blob/master/Release/CMakeLists.txt

Now build the project again:

cd casablanca/Release
cmake .
make

if everything is OK now you should have your executable created:
casablanca/Release/samples/granada/sessions-get-and-post/sessions-get-and-post

execute it and type http://localhost:80/ in your browser, you should see something like:

LOG:
---------------- Testing POST, session token in JSON ----------------
Session opened with token = XkrwFtQkCiCRC8uHJj2MIGQMUEnPYYLyO3pTWsPzlCy46JTPPix5ylyMvhY04YnO
Store value related to session =
Retrieve value related to session =
-------------- END Testing POST, session token in JSON --------------
---------------- Testing GET, session token in Query string ----------------
Session opened with token = S70Anug0wOR2IK0igP4ybZdCXH3OYbUW9NWEdPRw5lH5i0Qd5mShpud8tkcyvIW8
Store value related to session = testvalue!
Retrieve value related to session = testvalue!
-------------- END Testing GET, session token in Query string --------------

That's it.

Please tell if this was helpful or not and don't hesitate to contact if you have more problems providing more information like console logs, operative system you are using, if you successfully built a C++ REST SDK project ...

@alvarofcgm alvarofcgm self-assigned this Oct 20, 2016
@pulkitnandan
Copy link
Author

I'm using windows as development platform. Boost libraries seems to be the main issue here apart from pthreads.h.

Tried BOOST_ROOT but then it complains of not founding some libs

Boost version: 1.55.0

Boost include path: C:/local/boost_1_55_0

Could not find the following Boost libraries:

      boost_random
      boost_system
      boost_thread
      boost_locale
      boost_filesystem
      boost_chrono
      boost_atomic

@pulkitnandan
Copy link
Author

To build all targets on linux, it got stuck at
Built target redis-oauth2-server
[ 79%] Building CXX object samples/granada/plugin-server/CMakeFiles/plugin-server.dir/plugin-server.cpp.o
In file included from /home/rohitnandan/granada/spidermonkey/js/src/jsalloc.h:17:0,
from /home/rohitnandan/granada/spidermonkey/js/src/jsapi.h:26,
from /home/rohitnandan/casablanca/Release/include/granada/runner/spidermonkey_javascript_runner.h:34,
from /home/rohitnandan/casablanca/Release/include/granada/plugin/spidermonkey_plugin.h:33,
from /home/rohitnandan/casablanca/Release/include/granada/plugin/map_spidermonkey_plugin.h:31,
from /home/rohitnandan/casablanca/Release/samples/granada/plugin-server/plugin-server.cpp:31:
/home/rohitnandan/granada/spidermonkey/js/src/js/TypeDecls.h:23:23: fatal error: js-config.h: No such file or directory
compilation terminated.
samples/granada/plugin-server/CMakeFiles/plugin-server.dir/build.make:62: recipe for target 'samples/granada/plugin-server/CMakeFiles/plugin-server.dir/plugin-server.cpp.o' failed
make[2]: *** [samples/granada/plugin-server/CMakeFiles/plugin-server.dir/plugin-server.cpp.o] Error 1
CMakeFiles/Makefile2:1681: recipe for target 'samples/granada/plugin-server/CMakeFiles/plugin-server.dir/all' failed
make[1]: *** [samples/granada/plugin-server/CMakeFiles/plugin-server.dir/all] Error 2

@alvarofcgm
Copy link

alvarofcgm commented Oct 21, 2016

Hi and thanks for sharing,

So I suppose, you can build all the examples except the plug-in examples?

I think your problem here is related to Mozilla Spidermonkey lib. For the moment I have only tested granada with Spider Monkey version 38, so using newer versions and older versions will NOT work (99% sure) as the Spidermonkey lib evolves a lot in each release. So use version 38.

What I would recommend is you build the Mozilla Spidermonkey. See this link to check how to do it: Spidermonkey build documentation

In the CMakeList.txt of the example (Release/samples/granada/plugin-server/CMakeLists.txt) substitute the include_directories and link_directories paths by the real paths to your mozjs include and lib.

in my case it looks like this:

include_directories(/opt/mozjs-38.0.0/js/src/build_OPT.OBJ/dist/include)
link_directories(/opt/mozjs-38.0.0/js/src/build_OPT.OBJ/dist/lib)

(sorry, I have to document this better).

Build again the project and execute the generated executable, use a browser and type the URL: http://localhost to use the client application, if everything is OK you should see the math plug-ins in action.

If you are using Windows to build your project I recommend using Visual Studio. In the C++ REST SDK documentation Microsoft recommends not to try to build C++ REST SDK with CMake on Windows, they recommend to use Visual Studio 2013 (https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Windows).

Once you have the cpprestsdk built and functional on Windows you can build granada in Visual Studio as a static lib or dll (excluding the examples in the samples directory) building it first without the classes that use Redis and Mozilla Spidermonkey. Once you have granada built as a lib, build each example as a separate project that use the granada generated lib.

Run the resulting .exe as administrator.

@alvarofcgm
Copy link

Granada has been tested on Windows too using Visual Studio 2013 to build it. I have edited the previous comment adding this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants