Stiffstream/restinio

Problems with external dependencies

guteksan opened this issue · 12 comments

Hi,
I am trying to build restinio from sources, using mxx_ru for handling dependencies. So basically, I run these commands:

git clone https://github.com/stiffstream/restinio
cd restinio
mxxruexternals
cd dev
mkdir cmake_build
cd cmake_build
cmake -DCMAKE_INSTALL_PREFIX=target -DRESTINIO_FIND_DEPS=ON -DRESTINIO_SAMPLE=OFF -DRESTINIO_TEST=OFF -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target install

cmake failed having not found "unnoficial-http-parser".
Shouldn't running this mxxruexternals ensure that all external dependencies for restinio are downloaded? If I run with default values of RESTINIO_SAMPLE and RESTINIO_TEST, cmake fails also on not finding Catch2. I know these are optional dependencies, but my understanding was that mxx_ru will handle them, if necessary.

Hi!

Don't use -DRESTINIO_FIND_DEPS=ON if you use the acquisition of dependencies by mxxruexternals (or if you download archives like restinio-0.6.5-full.tar.bz2 with all dependencies inside).

The RESTINIO_FIND_DEPS option is for cases when you already have all dependencies installed via some other method (like usage of apt on Ubuntu or pacman on ArchLinux).

I am planning to build Restinio and create a debian package from it for local distrubution using apt. The documentation says: If it is planned to install RESTinio it is better to build it with -DRESTINIO_FIND_DEPS=ON so that RESTinio dependencies are propagated nicely to targets which depend on RESTinio., and I believe it is what I need, as I want to enclose Restinio with all its dependencies in one debian package, so that upon installation using apt, people can easily use Restinio in their cmake projects with find_package.

This phrase should tell that if someone is planned to install RESTinio and use it via INCLUDE path, then it's better to install RESTinio's dependencies separately and build RESTinio with -DRESTINIO_FIND_DEPS=ON. In that case, RESTinio will use already installed dependencies that are available via INCLUDE and LIB paths.

RESTinio by itself is a header-only library. The build command for your purposes is necessary only for copying RESTinio's files and making appropriate .cmake-files for find_package. And RESTinio by itself requires just libhttp-parser and libfmt

I think that for the creation of .deb package for RESTinio it's necessary to make a dependency of RESTinio's package from libhttp-parser-dev and libfmt-dev. Then RESTinio should be built with:

  • -DRESTINIO_FIND_DEPS=ON
  • -DRESTINIO_INSTALL=ON
  • -DRESTINIO_SAMPLE=OFF
  • -DRESTINIO_TEST=OFF
  • -DRESTINIO_BENCH=OFF
  • -DRESTINIO_USE_EXTERNAL_HTTP_PARSER=ON

But note, that since v.0.6.3 RESTinio requires fmtlib 6.1 or newer.

Sorry, I forgot about such dependency as Asio :(

Ok, so I am right that in my case I should not use mxx_ru prior to building Restinio, but install all dependencies manually using apt?

I am right that in my case I should not use mxx_ru prior to building Restinio, but install all dependencies manually using apt?

Yes.

Sorry, but I still have problems with dependencies, it is most likely asio.

  1. I installed via apt libasio-dev and libhttp-parser-dev
  2. I built and installed fmt (I will prepare debian package for fmt-dev later)
  3. I built and installed restinio with flags:
cmake -DRESTINIO_FIND_DEPS=ON -DRESTINIO_INSTALL=ON -DRESTINIO_SAMPLE=OFF -DRESTINIO_TEST=OFF -DRESTINIO_BENCH=OFF -DRESTINIO_USE_EXTERNAL_HTTP_PARSER=ON -DRESTINIO_ALLOW_SOBJECTIZER=OFF -DCMAKE_PREFIX_PATH=/home/guteksan/libs -DCMAKE_INSTALL_PREFIX=/home/guteksan/libs -DCMAKE_BUILD_TYPE=Release ..
  1. I have created a CMakeLists.txt for my project using restinio:
project(restinio-test)
find_package(fmt REQUIRED)
find_package(restinio REQUIRED)
...
add_executable(restinio-test ${SRC})

target_link_libraries(restinio-test PRIVATE 
	restinio::restinio
	fmt::fmt-header-only
)
  1. Cmake configuration runs fine, but building produces many errors, like:
/home/guteksan/libs/include/restinio/http_headers.hpp: In function \u2018constexpr restinio::http_method_id_t restinio::http_method_bind()\u2019:
/home/guteksan/libs/include/restinio/http_headers.hpp:1536:2: error: \u2018HTTP_BIND\u2019 was not declared in this scope
  RESTINIO_HTTP_METHOD_MAP( RESTINIO_HTTP_METHOD_FUNC_GEN )

Apparently, dependency to Asio should be added, but target asio is not available through find_package() - I thought that this is what -DRESTINIO_FIND_DEPS=ON is for. I noticed that installing libasio-dev does not install any cmake config file for it. How should I add dependency to asio then?

@guteksan can you provide information about your environment (OS, compiler version, versions of libasio-dev and libhttp-parser-dev)? Or maybe you can provide a Dockerfile with your build commands inside so I can reproduce your steps in my Kubuntu?

restinio-test-docker.zip
Hi,
I have prepared the dockerfile together with a minimalistic project to reproduce the problem. Please unzip these files and run `docker build .'

It seems that libhttp-parser-dev for ubuntu-16.04 contains http-parser v.2.1. There are no many HTTP methods that were added to http-parser at v.2.6. Like HTTP_BIND, HTTP_REBIND, HTTP_UNBIND.

We have started the development of RESTinio with http-parser v.2.7.1.

So I don't know how to make RESTinio work with such old versions of http-parser as v.2.1, v.2.2 and so on.

Can someone tell me where is mxxruexternals command?

eao197 commented

If you install Mxx_ru gem via:

gem install Mxx_ru

then mxxruexternals has to be added to your PATH automatically. On some platforms (like Archlinux, IIRC) that isn't the case and you have to modify your PATH manually:

export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="PATH:$GEM_HOME"

NOTE: Mxx_ru is a gem (package) for RubyGems and RubyGems is package manager for Ruby language.