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

Build instructions? #137

Open
ianklatzco opened this issue Mar 27, 2020 · 5 comments
Open

Build instructions? #137

ianklatzco opened this issue Mar 27, 2020 · 5 comments

Comments

@ianklatzco
Copy link

Hi,

I'm opening this issue to recommend a "build" section in the README with some brief instructions. Feel free to close it if that's duplicated anywhere.

Context:

I was trying to build master on a raspberry pi and got an error (at bottom). I git checkout 2.9 and built successfully.

Is master intended to successfully build? I looked around for building instructions in the README, but didn't see any, so I copied bits out of the Dockerfile (installing dependencies and running make).


g++ -O2 -c -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -Wformat -Wformat-security -Wno-format-nonliteral -Wall -Wextra -Werror -Ikafel/include -pthread  -std=c++11 -fno-exceptions -Wno-unused -Wno-unused-parameter -I/usr/include/libnl3  nsjail.cc -o nsjail.o
nsjail.cc: In function ‘bool nsjail::pipeTraffic(nsjconf_t*, int)’:
nsjail.cc:169:43: error: converting to ‘std::tuple<int, int, const char*>’ from initializer list would use explicit constructor ‘constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {unsigned int&, unsigned int, const char (&)[3]}; <template-parameter-2-2> = void; _Elements = {int, int, const char*}]’
        {i, i + 1, "in"}, {i + 2, i, "out"}};
                                           ^
nsjail.cc:169:43: error: converting to ‘std::tuple<int, int, const char*>’ from initializer list would use explicit constructor ‘constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {unsigned int, unsigned int&, const char (&)[4]}; <template-parameter-2-2> = void; _Elements = {int, int, const char*}]’
In file included from nsjail.cc:42:0:
logs.h:36:95: error: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG_D(...) logs::logMsg(logs::DEBUG, __PRETTY_FUNCTION__, __LINE__, false, __VA_ARGS__);
                                                                                               ^
nsjail.cc:177:6: note: in expansion of macro ‘LOG_D’
      LOG_D("#%ld piping data %s", pipe_no, direction);
      ^
logs.h:45:95: error: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define PLOG_E(...) logs::logMsg(logs::ERROR, __PRETTY_FUNCTION__, __LINE__, true, __VA_ARGS__);
                                                                                               ^
nsjail.cc:181:7: note: in expansion of macro ‘PLOG_E’
       PLOG_E("splice fd pair #%ld {%d, %d}\n", pipe_no,
       ^
logs.h:36:95: error: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG_D(...) logs::logMsg(logs::DEBUG, __PRETTY_FUNCTION__, __LINE__, false, __VA_ARGS__);
                                                                                               ^
nsjail.cc:196:5: note: in expansion of macro ‘LOG_D’
     LOG_D("#%ld connection closed", pipe_no);
     ^
nsjail.cc:201:29: error: missing initializer for member ‘pipemap_t::sock_fd’ [-Werror=missing-field-initializers]
     nsjconf->pipes[pipe_no] = {};
                             ^
nsjail.cc:201:29: error: missing initializer for member ‘pipemap_t::pipe_in’ [-Werror=missing-field-initializers]
nsjail.cc:201:29: error: missing initializer for member ‘pipemap_t::pipe_out’ [-Werror=missing-field-initializers]
nsjail.cc:208:91: error: missing initializer for member ‘pipemap_t::sock_fd’ [-Werror=missing-field-initializers]
  nsjconf->pipes.erase(std::remove(nsjconf->pipes.begin(), nsjconf->pipes.end(), pipemap_t{}),
                                                                                           ^
nsjail.cc:208:91: error: missing initializer for member ‘pipemap_t::pipe_in’ [-Werror=missing-field-initializers]
nsjail.cc:208:91: error: missing initializer for member ‘pipemap_t::pipe_out’ [-Werror=missing-field-initializers]
cc1plus: all warnings being treated as errors
Makefile:60: recipe for target 'nsjail.o' failed
make: *** [nsjail.o] Error 1
@happyCoder92
Copy link
Collaborator

Tuple errors seem to be an issue with an old compiler.
The behavior of tuple ctors was changed by n4387 applied as defect report to C++11.
Others should be fixed with 6eaed88.

@happyCoder92
Copy link
Collaborator

Actually the last errors are not tuple related but sill old compiler issues (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750)

@jvoisin
Copy link

jvoisin commented Jan 26, 2021

I concur, having build instruction with dependencies would be nice.
I'm trying to package nsjail for Alpine Linux, but the compilation fails:

Makefile:60: warning: ignoring prerequisites on suffix rule definition
git submodule update --init
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
g++ -Os -fomit-frame-pointer  -O2 -c -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -Wformat -Wformat-security -Wno-format-nonliteral -Wall -Wextra -Werror -Ikafel/include  -std=c++11 -fno-exceptions -Wno-unused -Wno-unused-parameter caps.cc -o caps.o
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
Package 'protobuf', required by 'virtual:world', not found
In file included from caps.h:28,
                 from caps.cc:22:
nsjail.h:26:10: fatal error: linux/filter.h: No such file or directory
   26 | #include <linux/filter.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

@tomjaguarpaw
Copy link

tomjaguarpaw commented Apr 9, 2021

On Debian the dependencies seem to be at least

  • g++
  • pkg-config
  • protobuf-compiler
  • libprotobuf-dev
  • flex
  • bison
  • libnl-route-3-dev

In Makefile I had to

  • add $(shell pkg-config --cflags libnl-3.0) to Makefile's COMMON_FLAGS
  • extend LD_FLAGS to contain $(shell pkg-config --libs protobuf libnl-3.0 libnl-nf-3.0 libnl-genl-3.0)

EDIT: actually I think the pkg-config edits were not required

@tomjaguarpaw
Copy link

In fact the Dockerfile is probably a good way to learn the dependencies.

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

4 participants