Build instructions?
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
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.
Actually the last errors are not tuple related but sill old compiler issues (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750)
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.
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)toMakefile'sCOMMON_FLAGS~ - ~extend
LD_FLAGSto 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
In fact the Dockerfile is probably a good way to learn the dependencies.