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

Cannot find path. Unable to use restc-cpp #46

Closed
privateOmega opened this issue Feb 26, 2018 · 8 comments
Closed

Cannot find path. Unable to use restc-cpp #46

privateOmega opened this issue Feb 26, 2018 · 8 comments

Comments

@privateOmega
Copy link

Using the example program
`#include
#include "restc-cpp/restc-cpp.h"

using namespace std;
using namespace restc_cpp;

void DoSomethingInteresting(Context& ctx) {
// Here we are in a co-routine, running in a worker-thread.

// Asynchronously connect to a server and fetch some data.
auto reply = ctx.Get("http://jsonplaceholder.typicode.com/posts/1");

// Asynchronously fetch the entire data-set and return it as a string.
auto json = reply->GetBodyAsString();

// Just dump the data.
cout << "Received data: " << json << endl;

}

int main() {
auto rest_client = RestClient::Create();

// Call DoSomethingInteresting as a co-routine in a worker-thread.
rest_client->Process(DoSomethingInteresting);

// Wait for the coroutine to finish, then close the client.
rest_client->CloseWhenReady(true);

}
`
VSCode shows #include errors detected. Please update your includePath. IntelliSense features for this translation unit (/home/kiran/dave/src/rest-client.cpp) will be provided by the Tag Parser.
cannot open source file "restc-cpp/restc-cpp.h"

I have followed the build instructions for ubuntu to the letter.
`sudo apt-get install zlib1g-dev g++ cmake doxygen graphviz libboost-all-dev libssl-dev

git clone https://github.com/jgaa/restc-cpp.git
cd restc-cpp/
mkdir dbuild
cd dbuild
cmake ..
make`

@jgaa
Copy link
Owner

jgaa commented Feb 26, 2018

I think you need to add the include-paths.
The simplest way is probably to make the library and then "sudo make install" it. That will copy the headers to /usr/local/include. Then you just have to make sure that VSCode look for includes in /usr/local/include.

There are examples on how to link a project in the examples folder, both with cmake and from the command line.

@jgaa jgaa closed this as completed Feb 26, 2018
@privateOmega
Copy link
Author

@jgaa What happened after sudo make install

`Scanning dependencies of target redirect_tests
[ 95%] Building CXX object tests/functional/CMakeFiles/redirect_tests.dir/RedirectTests.cpp.o
[ 97%] Linking CXX executable redirect_tests
[ 97%] Built target redirect_tests
Scanning dependencies of target logip
[ 98%] Building CXX object examples/logip/CMakeFiles/logip.dir/logip.cpp.o
[100%] Linking CXX executable logip
[100%] Built target logip
Install the project...
-- Install configuration: ""
CMake Error at cmake_install.cmake:36 (file):
file INSTALL cannot find
"/home/kiran/restc-cpp/dbuild/external-projects/installed/include/rapidjson".

Makefile:126: recipe for target 'install' failed
make: *** [install] Error 1
`

@jgaa
Copy link
Owner

jgaa commented Feb 27, 2018

The rapidjson headers are there, if not, restc-cpp would no build. But something is broken. I'll add the install and compilation of the test programs to the automated tests and see if I can reproduce the problem.
What operating system are you using?

@privateOmega
Copy link
Author

I've tried the same on Ubuntu 16.04 and 14.04

@jgaa
Copy link
Owner

jgaa commented Feb 27, 2018

I found the problem. I changed the way i handle the external rapidjson project in cmake a while ago. My automated tests passed, and I never tested the 'make install' after that.

I have committed a fix to the master branch.

@privateOmega
Copy link
Author

Thanks @jgaa I will try it out.

@privateOmega
Copy link
Author

@jgaa It worked like a charm. Appreciate it.
Just some things on my mind that need your expertise. Are all the library linking necessary? Which all can be avoided? I am asking out of curiosity and the next thing is how can I disable the tracing. It kind of hogs my screen.

@jgaa
Copy link
Owner

jgaa commented Feb 28, 2018

You will probably need all the libraries for any production build. The boost libraries are required for both IO, json serialization, logging and coroutines.

You can avoid zlib by calling cmake with -DRESTC_CPP_WITH_ZLIB=OFF

You can avoid openssl by calling cmake with -DRESTC_CPP_WITH_TLS=OFF

To relax the logging, just put the log-level you want in your main function

#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>

int main( int argc, char * argv[] )
{
    namespace logging = boost::log;
    logging::core::get()->set_filter
    (
        logging::trivial::severity >= logging::trivial::debug
    );

If debug is too verbose, you may use info or warning in stead.

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

No branches or pull requests

2 participants