PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.69k stars 906 forks source link

rec_control: ld: library not found for -lcrypto #11855

Closed zeha closed 2 years ago

zeha commented 2 years ago

Short description

make fails to link rec_control on macOS 12: ld: library not found for -lcrypto

Environment

Steps to reproduce

  1. configure recursordist, PKG_CONFIG_PATH=/opt/homebrew/opt/openssl@1.1/lib/pkgconfig:/opt/homebrew/opt/sqlite3/lib/pkgconfig --with-boost=/opt/homebrew
  2. make
  3. observe pdns_recursor links, but rec_control does not

Expected behaviour

it should just link

Actual behaviour

/bin/sh ./libtool  --tag=CXX   --mode=link g++ -std=c++17 -DSYSCONFDIR=\"/usr/local/etc\" -DPKGLIBDIR=\"/usr/local/lib/pdns-recursor\" -DLOCALSTATEDIR=\"/var/run\" -DNODCACHEDIR=\"/usr/local/var/lib/pdns-recursor\" -fPIE -DPIE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 --param ssp-buffer-size=4 -fstack-protector -D__APPLE_USE_RFC_3542 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -Wall -Wextra -Wshadow -Wno-unused-parameter -Wmissing-declarations -Wredundant-decls -fvisibility=hidden -g -O2  -Wl,-pie    -o rec_control arguments.o base64.o credentials.o dnslabeltext.o dnsname.o logger.o logging.o misc.o qtype.o rec_channel.o rec_control.o unix_utility.o -lcrypto -L/opt/homebrew/Cellar/libsodium/1.0.18_1/lib -lsodium
libtool: link: g++ -std=c++17 -DSYSCONFDIR=\"/usr/local/etc\" -DPKGLIBDIR=\"/usr/local/lib/pdns-recursor\" -DLOCALSTATEDIR=\"/var/run\" -DNODCACHEDIR=\"/usr/local/var/lib/pdns-recursor\" -fPIE -DPIE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 --param ssp-buffer-size=4 -fstack-protector -D__APPLE_USE_RFC_3542 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -Wall -Wextra -Wshadow -Wno-unused-parameter -Wmissing-declarations -Wredundant-decls -fvisibility=hidden -g -O2 -Wl,-pie -o rec_control arguments.o base64.o credentials.o dnslabeltext.o dnsname.o logger.o logging.o misc.o qtype.o rec_channel.o rec_control.o unix_utility.o -Wl,-bind_at_load  -lcrypto -L/opt/homebrew/Cellar/libsodium/1.0.18_1/lib -lsodium
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Other information

General observation: It looks like various parts assume openssl is always available in the default include and library paths. I think sometimes this can also lead to using headers from the default include path, but then linking against another libcrypto.

I think some long time ago the idea was that different crypto libraries could be used, but now you must have openssl, and so everything just assumes its fine to use it. But then the openssl CFLAGS/LDFLAGS should maybe be added to all compilation and link steps.

omoerbeek commented 2 years ago

I'm building with:

export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"

export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"

On MacOS 12.5.

zeha commented 2 years ago

I'm building with:

export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"

export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"

On MacOS 12.5.

Yeah, that certainly works. But it should not be necessary: the correct flags are already looked up from pkgconfig. They are just not passed to all the necessary places.