DNS-OARC / flamethrower

a DNS performance and functional testing utility supporting UDP, TCP, DoT and DoH
Apache License 2.0
319 stars 37 forks source link

compilation fails with DOH_ENABLE=ON #64

Closed nicki-krizek closed 3 years ago

nicki-krizek commented 3 years ago

When I try to compile flamethrower with DoH support:

mkdir build; cd build
cmake -DDOH_ENABLE=ON ..
make

I get an error:

/usr/bin/c++ -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -g -fvar-tracking-assignments -fdebug-prefix-map=/home/tkrizek/aur/flamethrower/src=/usr/src/debug -g -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now CMakeFiles/flame.dir/3rd/docopt.cpp/docopt.cpp.o CMakeFiles/flame.dir/3rd/url-parser/url_parser.c.o CMakeFiles/flame.dir/flame/main.cpp.o CMakeFiles/flame.dir/3rd/base64url/base64.cpp.o -o flame  libflamecore.a -luv -ldl -luv -ldl -lldns -lldns -lgnutls -lgnutls -lnghttp2 -lnghttp2 
/usr/bin/ld: CMakeFiles/flame.dir/flame/main.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib/libpthread.so.0: error adding symbols: DSO missing from command line

My workaround is to use export LDFLAGS='-pthread' but it seems like a cmake configuration issue.

weyrick commented 3 years ago

Thanks @tomaskrizek, we'll look into it. What platform/distro are you on?

nicki-krizek commented 3 years ago

I'm using Archlinux on x86_64 with cmake 3.20.0.

jroyalty commented 3 years ago

I encountered this issue even without building for DoH. Because std::thread is referenced in main.cpp it's a requirement for all builds (unless it's #ifdef'd out).

Regardless, telling CMake to search for a threads library does the trick on my Ubuntu 18.04 machine. If you want to test on other distros, here's the diff: https://github.com/DNS-OARC/flamethrower/compare/master...jroyalty:build-with-threading-lib

weyrick commented 3 years ago

@tomaskrizek I have merged the changes from @jroyalty , can you try again?

nicki-krizek commented 3 years ago

It seems to work now, thanks!