-
Notifications
You must be signed in to change notification settings - Fork 6
Building
This is a short guideline providing information for building pcapFS independent from your linux distribution.
First, you need to install all build tools.
This means, CMake, gcc, binutils, boost (if you can, do it from your packet manager and install boost plus the boost-development packages, otherwise use the install script). If some step is failing, install the regarding build tool (and open a ticket on the bugtracker so we can update the wiki).
Next, install the dependencies accordingly to the helper-scripts. They won't run any make install
copying files into your system folders, instead they install all dependencies into the dependencies folder in the project's folder pcapFS/dependencies.
The scripts are located in pcapFS/scripts/dependencies:
(Read the scripts before launching any of them to prove if they fit to your needs and environments)
Change into the directory pcapFS/scripts/dependencies and run the scripts accordingly:
cd pcapFS/scripts/dependencies
./install-cpptoml.sh
./install-openssl.sh
./install-json.sh
./install-pcap-plus-plus.sh
./install-fuse.sh
./install-fusepp.sh
If you could install the boost development packages for your distribution via packetmanager you should be able ti build the project, otherwise build it manually as dependency:
./install-boost.sh
Then you can build the project:
cd pcapFS/build
cmake ../
cd ..
make -j9
If any error occurs when building a dependency or the project itself, please open a bugreport.
Here are common problems listed which can result in build fails:
At the time of writing there was some trouble building an openssl library independent from the system's version. This can lead to problems, since many systems still do not use openssl >=1.1.1. CMake seems trying to use the OpenSSL version of the system and not the provided version in the dependency folder.
The following section contains a small workaround for the CMake find_package(Openssl 1.1 REQUIRED)
call:
find_package(Boost COMPONENTS filesystem iostreams log program_options system serialization REQUIRED)
find_package(cpptoml REQUIRED)
find_package(FUSE3 REQUIRED)
find_package(Fusepp REQUIRED)
find_package(nlohmann_json REQUIRED)
#find_package(OpenSSL 1.1 REQUIRED)
#
# This does not work (Full Path does not work, too):
# cmake -DOPENSSL_LIBRARIES=dependencies/lib -DOPENSSL_ROOT_DIR=dependencies/include/openssl ../
#
# BUG?
# copied from here (workaround by Chris Wilson):
# https://gitlab.kitware.com/cmake/cmake/issues/17604
#
find_package(OpenSSL)
set(OPENSSL_SSL_LIBRARY dependencies/lib)
set(OPENSSL_INCLUDE_DIR dependencies/include/openssl)
set(OPENSSL_CRYPTO_LIBRARY dependencies/lib)
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
find_package_handle_standard_args(OpenSSL
REQUIRED_VARS
OPENSSL_SSL_LIBRARY
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR"
)
find_package(PcapPlusPlus REQUIRED)
find_package(ZLIB REQUIRED)
Overwrite the line find_package(OpenSSL 1.1 REQUIRED)
in the File pcapFS/CMakeLists.txt
, so it looks like this file:
cmake_minimum_required(VERSION 3.8)
project(pcapFS VERSION 0.2.0 LANGUAGES CXX)
set(PCAPFS_INDEX_VERSION_MAJOR 0)
set(PCAPFS_INDEX_VERSION_MINOR 2)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/dependencies/)
list(INSERT CMAKE_INCLUDE_PATH 0 ${CMAKE_SOURCE_DIR}/dependencies/include/)
set(ENV{PKG_CONFIG_PATH}
${CMAKE_SOURCE_DIR}/dependencies/lib/pkgconfig/:${CMAKE_SOURCE_DIR}/dependencies/lib64/pkgconfig/)
configure_file(${CMAKE_SOURCE_DIR}/src/versions.h.in ${CMAKE_SOURCE_DIR}/src/versions.h)
find_package(Boost COMPONENTS filesystem iostreams log program_options system serialization REQUIRED)
find_package(cpptoml REQUIRED)
find_package(FUSE3 REQUIRED)
find_package(Fusepp REQUIRED)
find_package(nlohmann_json REQUIRED)
#find_package(OpenSSL 1.1 REQUIRED)
#
# This does not work (Full Path does not work, too):
#
# cmake -DOPENSSL_LIBRARIES=dependencies/lib -DOPENSSL_ROOT_DIR=dependencies/include/openssl ../
#
# BUG?
# copied from here:
# https://gitlab.kitware.com/cmake/cmake/issues/17604
#
find_package(OpenSSL)
set(OPENSSL_SSL_LIBRARY dependencies/lib)
set(OPENSSL_INCLUDE_DIR dependencies/include/openssl)
set(OPENSSL_CRYPTO_LIBRARY dependencies/lib)
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
find_package_handle_standard_args(OpenSSL
REQUIRED_VARS
OPENSSL_SSL_LIBRARY
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR"
)
find_package(PcapPlusPlus REQUIRED)
find_package(ZLIB REQUIRED)
set(PCAPFS_COMMON_SOURCES
src/commontypes.h
src/config.cpp
src/decodemap.h
src/exceptions.h
src/index.cpp
src/offsets.h
src/logging.cpp
src/properties.h
src/utils.cpp
src/pcapfs.cpp
src/dirlayout.cpp
src/filefactory.cpp
src/file.cpp
src/capturefiles/capturefile.cpp
src/capturefiles/pcap.cpp
src/capturefiles/pcapng.cpp
src/keyfiles/sslkey.cpp
src/keyfiles/xorkey.cpp
src/virtualfiles/virtualfile.cpp
src/virtualfiles/ftp.cpp
src/virtualfiles/ftpcontrol.cpp
src/virtualfiles/ftp/ftp_commands.cpp
src/virtualfiles/ftp/ftp_response_codes.h
src/virtualfiles/ftp/ftp_port_bridge.cpp
src/virtualfiles/dns.cpp
src/virtualfiles/http.cpp
src/virtualfiles/ssl.cpp
src/virtualfiles/tcp.cpp
src/virtualfiles/udp.cpp
src/virtualfiles/xor.cpp
)
set(PCAPFS_LINK_LIBRARIES
Boost::filesystem Boost::iostreams Boost::log Boost::program_options Boost::system Boost::serialization
FUSE3::FUSE3
Fusepp::Fusepp
nlohmann_json::nlohmann_json
OpenSSL::SSL
OpenSSL::Crypto
PcapPlusPlus::PcapPlusPlus
ZLIB::ZLIB
)
set(COMPILE_FEATURES cxx_std_14)
add_executable(pcapfs src/main.cpp ${PCAPFS_COMMON_SOURCES})
target_compile_options(pcapfs PRIVATE -Wall -Wextra)
target_compile_features(pcapfs PRIVATE ${COMPILE_FEATURES})
target_link_libraries(pcapfs PRIVATE ${PCAPFS_LINK_LIBRARIES})
if (BUILD_TESTING)
find_package(Catch2 REQUIRED)
include(CTest)
include(Catch)
set(TEST_PCAP_PATH ${CMAKE_SOURCE_DIR}/tests/system/system-tests.pcap)
set(UNIT_TEST_KEY_FILE_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/unit/keyfiles)
configure_file(${CMAKE_SOURCE_DIR}/tests/unit/constants.h.in ${CMAKE_SOURCE_DIR}/tests/unit/constants.h)
add_executable(unittests
${PCAPFS_COMMON_SOURCES}
tests/unit/main.cpp
tests/unit/test-command-line-options.cpp
)
target_compile_features(unittests PRIVATE ${COMPILE_FEATURES})
target_link_libraries(unittests PRIVATE ${PCAPFS_LINK_LIBRARIES} Catch2::Catch2)
catch_discover_tests(unittests)
endif ()
Please keep in mind that the CMakeLists.txt
file of the project may change and this wiki page might not be updated as fast as the build file. Overwrite only the line find_package(OpenSSL 1.1 REQUIRED)
with the provided workaround and keep the rest of the file.