seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.69k stars 655 forks source link

Linux build is failing, kindly assist #1611

Open zyl-one opened 10 hours ago

zyl-one commented 10 hours ago

I am trying to build from source for Linux with v23.09, the build keeps failing with this error:

[  1%] Building CXX object 3rdParty/hash-library/CMakeFiles/hash-library.dir/md5.cpp.o
[  1%] Built target hash-library
[  2%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_advanced.c.o
[  3%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_alloc.c.o
[  4%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_compression.c.o
[  5%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_internal.c.o
[  6%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_io.c.o
[  7%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_manipulate.c.o
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c: In function 'light_ip_flow':
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c:419:4: warning: missing braces around initializer [-Wmissing-braces]
    flow_address_t flow_key = {0};
    ^
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c:419:4: warning: (near initialization for 'flow_key.source') [-Wmissing-braces]
[  8%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_null_compression.c.o
[  9%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_option.c.o
[ 10%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_pcapng_cont.c.o
[ 11%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_pcapng_ext.c.o
[ 12%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_pcapng.c.o
[ 13%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_platform.c.o
[ 15%] Building C object 3rdParty/LightPcapNg/CMakeFiles/light_pcapng.dir/LightPcapNg/src/light_zstd_compression.c.o
[ 15%] Built target light_pcapng
[ 16%] Building CXX object Common++/CMakeFiles/Common++.dir/src/GeneralUtils.cpp.o
[ 17%] Building CXX object Common++/CMakeFiles/Common++.dir/src/IpAddress.cpp.o
[ 18%] Building CXX object Common++/CMakeFiles/Common++.dir/src/IpUtils.cpp.o
[ 19%] Building CXX object Common++/CMakeFiles/Common++.dir/src/Logger.cpp.o
[ 20%] Building CXX object Common++/CMakeFiles/Common++.dir/src/MacAddress.cpp.o
[ 21%] Building CXX object Common++/CMakeFiles/Common++.dir/src/OUILookup.cpp.o
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/Common++/src/OUILookup.cpp: In instantiation of 'int64_t pcpp::OUILookup::internalParser(T&) [with T = std::basic_ifstream<char>; int64_t = long int]':
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/Common++/src/OUILookup.cpp:77:32:   required from here
/test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/Common++/src/OUILookup.cpp:40:50: error: converting to 'std::unordered_map<long unsigned int, std::basic_string<char> >' from initializer list would use explicit constructor 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = long unsigned int; _Tp = std::basic_string<char>; _Hash = std::hash<long unsigned int>; _Pred = std::equal_to<long unsigned int>; _Alloc = std::allocator<std::pair<const long unsigned int, std::basic_string<char> > >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type = long unsigned int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hasher = std::hash<long unsigned int>; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<long unsigned int>; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<const long unsigned int, std::basic_string<char> > >]'
      vLocalMaskedFilter.push_back({maskValue, {}});
                                                  ^
gmake[2]: *** [Common++/CMakeFiles/Common++.dir/src/OUILookup.cpp.o] Error 1
gmake[1]: *** [Common++/CMakeFiles/Common++.dir/all] Error 2
gmake: *** [all] Error 2

Here is the build command stack to generate the ./linuxBuild folder:

+ cmake -DPCAPPP_BUILD_TESTS=OFF -DPCAPPP_BUILD_EXAMPLES=OFF -DPCAPPP_BUILD_TUTORIALS=OFF -S . -B ./linuxBuild
-- The CXX compiler identification is GNU 4.9.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/rh/devtoolset-3/root/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 4.9.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/rh/devtoolset-3/root/usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PCAP: /usr/lib64/libpcap.so  
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_set_immediate_mode
-- Looking for pcap_set_immediate_mode - found
-- Looking for pcap_setdirection
-- Looking for pcap_setdirection - found
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring done
+ cmake --build ./linuxBuild
-- Generating done
-- Build files have been written to: /test/build/WH_DIR/Oct_09_2024/my_product/my_product_9237749/my_product_DBUILD/build/my_product/native/PcapPlusPlus/linuxBuild

@clementperon @egecetin

seladb commented 9 hours ago

@zyl-one did you try building v24.09?

egecetin commented 9 hours ago

@zyl-one @seladb GCC 4.9.1 is a bit outdated. Maybe a compiler related error?

zyl-one commented 9 hours ago

@seladb I have already developed my custom application which depends on v23.09. Forced to use v23.09 now (Can't update to latest as of now).

seladb commented 8 hours ago

@zyl-one @seladb GCC 4.9.1 is a bit outdated. Maybe a compiler related error?

@zyl-one can you try to build it on a later version of GCC?