error when making libnethogs
gkarsai opened this issue · 4 comments
To reproduce:
make libnethogs
It fails on lines 162 and 187 of src/connection.cpp.
Note:
make
does NOT fail because it does not use the std=c++0x flag. If that flag is used, compilation fails.
Probable cause:
ConnList has been changed to multiset<Connection*,COMPFUNCTION>. A Packet is passed as an argument for the lower_bound(Connection*) method, that results in a type violation.
It compiles for C++14 (or later) - and the multiset implementation has been changed to work with 'narrower' keys.
Suggest removing (or replacing) the std=c++0x flag.
It works for me:
make -C src -f MakeApp.mk clean
make[1]: Entering directory '/home/aengelen/dev/nethogs/src'
rm -f packet.o connection.o process.o decpcap.o cui.o inode2prog.o conninode.o devices.o
rm -f conninode_test
rm -f nethogs
rm -f test
rm -f decpcap_test
make[1]: Leaving directory '/home/aengelen/dev/nethogs/src'
make -C src -f MakeLib.mk clean
make[1]: Entering directory '/home/aengelen/dev/nethogs/src'
rm -f obj/lib/release/libnethogs.o obj/lib/release/packet.o obj/lib/release/connection.o obj/lib/release/process.o obj/lib/release/decpcap.o obj/lib/release/inode2prog.o obj/lib/release/conninode.o obj/lib/release/devices.o
rm -f libnethogs.so.0.8.7-16-g80df004
rm -f libnethogs.a
mkdir -p obj/lib/release
rmdir -p --ignore-fail-on-non-empty obj/lib/release
make[1]: Leaving directory '/home/aengelen/dev/nethogs/src'
make -C src -f MakeLib.mk all
make[1]: Entering directory '/home/aengelen/dev/nethogs/src'
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/libnethogs.o -c libnethogs.cpp -DVERSION=\"0.8.7-16-g80df004\"
libnethogs.cpp: In function ‘void nethogsmonitor_breakloop()’:
libnethogs.cpp:338:8: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
338 | write(self_pipe.second, "x", 1);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/packet.o -c packet.cpp
In file included from /nix/store/mmmjp0xcmr0dm307jv1l34hvi95z6d8s-glibc-2.35-224-dev/include/sys/types.h:25,
from /nix/store/mmmjp0xcmr0dm307jv1l34hvi95z6d8s-glibc-2.35-224-dev/include/net/ethernet.h:24,
from packet.h:27,
from packet.cpp:23:
/nix/store/mmmjp0xcmr0dm307jv1l34hvi95z6d8s-glibc-2.35-224-dev/include/features.h:194:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
194 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
| ^~~~~~~
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/connection.o -c connection.cpp
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/process.o -c process.cpp
gcc -Wall -Wextra -O3 -fPIC -fvisibility=hidden -o obj/lib/release/decpcap.o -c decpcap.c
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/inode2prog.o -c inode2prog.cpp
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/conninode.o -c conninode.cpp
conninode.cpp: In function ‘int addprocinfo(const char*, std::map<std::__cxx11::basic_string<char>, long unsigned int>&)’:
conninode.cpp:174:8: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
174 | fgets(buffer, sizeof(buffer), procinfo);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -o obj/lib/release/devices.o -c devices.cpp
g++ -Wall -Wextra -Wno-missing-field-initializers --std=c++14 -O3 -fPIC -fvisibility=hidden -shared -Wl,-soname,libnethogs.so.0.8.7-16-g80df004 obj/lib/release/libnethogs.o obj/lib/release/packet.o obj/lib/release/connection.o obj/lib/release/process.o obj/lib/release/decpcap.o obj/lib/release/inode2prog.o obj/lib/release/conninode.o obj/lib/release/devices.o -o libnethogs.so.0.8.7-16-g80df004 -lpcap
ar rcs libnethogs.a obj/lib/release/libnethogs.o obj/lib/release/packet.o obj/lib/release/connection.o obj/lib/release/process.o obj/lib/release/decpcap.o obj/lib/release/inode2prog.o obj/lib/release/conninode.o obj/lib/release/devices.o
make[1]: Leaving directory '/home/aengelen/dev/nethogs/src'
Can you clarify what the difference might be? Possibly related to #223 /cc @CyberShadow
I think this was fixed in 4c30af3.
I am building from the release 0.8.7, and there the MakeLib (and the Python binding's setup) includes the --std=c++0x flag, but the code works only for c++14 or later. The main branch includes the flags for c++14 (and c++17 for Python) , so the compilation (as above) succeeds.
Thanks for checking!