Skip to content

Comments

Added docker build example#5

Open
dagelf wants to merge 1 commit intolibtins:masterfrom
dagelf:patch-5
Open

Added docker build example#5
dagelf wants to merge 1 commit intolibtins:masterfrom
dagelf:patch-5

Conversation

@dagelf
Copy link
Contributor

@dagelf dagelf commented Mar 3, 2018

No description provided.

@mfontanini
Copy link
Collaborator

Can you expand on what "random dependency errors" you got while compiling something that uses libtins and how those docker images fixed it?

@dagelf
Copy link
Contributor Author

dagelf commented Mar 12, 2018

It's got a pretty good make system, and I didn't get any, but out of habit I build things like this just in case. One could easily spend an hour or more just trying to find the right dependencies... I'd rather find them in a standardized environment so it could benefit more people than just me.

Docker gives you a known good build environment with one command.

There might not be build instructions for building with different C libraries and different distributions, and you might like to contribute to- or build a utility that uses libtins, rather than spending your time just trying to figure out how to build it perfectly for your distribution or environment - in which case this answer in the FAQ could help you to spend 2 hours getting to know libtins, rather than just trying to get it to build.

For example - building on alpine:


/libtins/x # cmake ..
-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Build will generate a shared library. Use LIBTINS_BUILD_SHARED=0 to perform a static build
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PCAP (missing: PCAP_LIBRARY PCAP_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/FindPCAP.cmake:46 (find_package_handle_standard_args)
  CMakeLists.txt:60 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/libtins/x/CMakeFiles/CMakeOutput.log".
See also "/libtins/x/CMakeFiles/CMakeError.log".
/libtins/x # apk add pcap-dev
ERROR: unsatisfiable constraints:
  pcap-dev (missing):
    required by: world[pcap-dev]
/libtins/x # apk add libpcap-dev
(1/2) Installing libpcap (1.8.1-r1)
(2/2) Installing libpcap-dev (1.8.1-r1)
Executing busybox-1.27.2-r7.trigger
OK: 209 MiB in 47 packages
/libtins/x # cmake ..
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Build will generate a shared library. Use LIBTINS_BUILD_SHARED=0 to perform a static build
-- Found PCAP: /usr/lib/libpcap.so  
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_get_pfring_id
-- Looking for pcap_get_pfring_id - not found
-- Looking for pcap_set_immediate_mode
-- Looking for pcap_set_immediate_mode - found
-- Looking for pcap_set_tstamp_precision
-- Looking for pcap_set_tstamp_precision - found
-- Performing Test _HAS_CXX11_FLAG
-- Performing Test _HAS_CXX11_FLAG - Success
-- Checking C++ support for "decltype"
-- Checking C++ support for "decltype": works
-- Checking C++ support for "declval"
-- Checking C++ support for "declval": works
-- Checking C++ support for "initializer_list"
-- Checking C++ support for "initializer_list": works
-- Checking C++ support for "rvalue-references"
-- Checking C++ support for "rvalue-references": works
-- Checking C++ support for "functional"
-- Checking C++ support for "functional": works
-- Checking C++ support for "chrono"
-- Checking C++ support for "chrono": works
-- Checking C++ support for "noexcept"
-- Checking C++ support for "noexcept": works
-- Checking C++ support for "builtin-swap"
-- Checking C++ support for "builtin-swap": works
-- Enabling C++11 features
-- Enabling IEEE 802.11 support.
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
CMake Warning at CMakeLists.txt:136 (MESSAGE):
  Disabling WPA2 decryption support since OpenSSL was not found


-- Enabling TCPIP classes
-- Could NOT find Boost
CMake Warning at CMakeLists.txt:167 (MESSAGE):
  Disabling ACK tracking support as boost.icl was not found


CMake Warning at CMakeLists.txt:183 (MESSAGE):
  Disabling TCP stream custom data support as boost.any was not found


CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:552 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:892 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1523 (_Boost_MISSING_DEPENDENCIES)
  examples/CMakeLists.txt:2 (FIND_PACKAGE)


-- Could NOT find Boost
CMake Warning at examples/CMakeLists.txt:27 (MESSAGE):
  Disabling HTTP requests example since boost.regex was not found


-- googletest git submodule is absent. Run `git submodule init && git submodule update` to get it
-- Configuring done
-- Generating done
-- Build files have been written to: /libtins/x
/libtins/x # make
Scanning dependencies of target tins
[  0%] Building CXX object src/CMakeFiles/tins.dir/address_range.cpp.o
[  1%] Building CXX object src/CMakeFiles/tins.dir/arp.cpp.o
[  2%] Building CXX object src/CMakeFiles/tins.dir/bootp.cpp.o
[  4%] Building CXX object src/CMakeFiles/tins.dir/crypto.cpp.o
[  5%] Building CXX object src/CMakeFiles/tins.dir/detail/address_helpers.cpp.o
[  7%] Building CXX object src/CMakeFiles/tins.dir/detail/icmp_extension_helpers.cpp.o
[  8%] Building CXX object src/CMakeFiles/tins.dir/detail/pdu_helpers.cpp.o
[  9%] Building CXX object src/CMakeFiles/tins.dir/detail/sequence_number_helpers.cpp.o
[ 11%] Building CXX object src/CMakeFiles/tins.dir/dhcp.cpp.o
[ 12%] Building CXX object src/CMakeFiles/tins.dir/dhcpv6.cpp.o
[ 14%] Building CXX object src/CMakeFiles/tins.dir/dns.cpp.o
[ 15%] Building CXX object src/CMakeFiles/tins.dir/dot3.cpp.o
[ 16%] Building CXX object src/CMakeFiles/tins.dir/dot1q.cpp.o
[ 18%] Building CXX object src/CMakeFiles/tins.dir/eapol.cpp.o
[ 19%] Building CXX object src/CMakeFiles/tins.dir/ethernetII.cpp.o
[ 21%] Building CXX object src/CMakeFiles/tins.dir/handshake_capturer.cpp.o
[ 22%] Building CXX object src/CMakeFiles/tins.dir/hw_address.cpp.o
[ 23%] Building CXX object src/CMakeFiles/tins.dir/icmp_extension.cpp.o
[ 25%] Building CXX object src/CMakeFiles/tins.dir/icmp.cpp.o
[ 26%] Building CXX object src/CMakeFiles/tins.dir/icmpv6.cpp.o
[ 28%] Building CXX object src/CMakeFiles/tins.dir/ip_reassembler.cpp.o
[ 29%] Building CXX object src/CMakeFiles/tins.dir/ip.cpp.o
[ 30%] Building CXX object src/CMakeFiles/tins.dir/ip_address.cpp.o
[ 32%] Building CXX object src/CMakeFiles/tins.dir/ipv6.cpp.o
[ 33%] Building CXX object src/CMakeFiles/tins.dir/ipv6_address.cpp.o
[ 35%] Building CXX object src/CMakeFiles/tins.dir/ipsec.cpp.o
[ 35%] Building CXX object src/CMakeFiles/tins.dir/llc.cpp.o
[ 36%] Building CXX object src/CMakeFiles/tins.dir/loopback.cpp.o
[ 38%] Building CXX object src/CMakeFiles/tins.dir/mpls.cpp.o
[ 39%] Building CXX object src/CMakeFiles/tins.dir/memory_helpers.cpp.o
[ 40%] Building CXX object src/CMakeFiles/tins.dir/network_interface.cpp.o
/libtins/src/network_interface.cpp:42:37: fatal error: linux/if_packet.h: No such file or directory
         #include <linux/if_packet.h>
                                     ^
compilation terminated.
make[2]: *** [src/CMakeFiles/tins.dir/build.make:783: src/CMakeFiles/tins.dir/network_interface.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: src/CMakeFiles/tins.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I can just carry on doing "apk add" and building dependencies until it works... but if I use docker I could spend that time actually going into the code, rather than the build process.

For the record, building on alpine, here are the dependencies installed so far, if someone wants to spend more time on that:

apk update
apk add git cmake gcc libpcap-dev g++

Update:

apk update
apk add git cmake gcc libpcap-dev boost-dev g++

Is all that is needed to build it properly on Alpine linux!
I just added a dockerfile for that on my repo.

@mfontanini
Copy link
Collaborator

The list of dependencies is actually really small, it shouldn't really take you an hour to get it set up, there's even a list of the dependencies in the README file. Maybe it's worth adding a wiki entry stating which specific packages you need in each distro?

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

Successfully merging this pull request may close these issues.

2 participants