When building on mac, ld: library not found for -lcrypto
kravigupta opened this issue · 7 comments
I was trying to build on mac I see errors.
ravi-mac:Restweb ravi.gupta$ cmake .
-- Boost version: 1.67.0
-- Found the following Boost libraries:
-- random
-- system
-- thread
-- filesystem
-- chrono
-- atomic
-- date_time
-- regex
-- Boost_INCLUDE_DIRS: /usr/local/include
-- Boost_LIBRARIES: /usr/local/lib/libboost_random-mt.dylib;/usr/local/lib/libboost_system-mt.dylib;/usr/local/lib/libboost_thread-mt.dylib;/usr/local/lib/libboost_filesystem-mt.dylib;/usr/local/lib/libboost_chrono-mt.dylib;/usr/local/lib/libboost_atomic-mt.dylib;/usr/local/lib/libboost_date_time-mt.dylib;/usr/local/lib/libboost_regex-mt.dylib
-- Boost_VERSION: 106700
-- OPENSSL_INCLUDE_DIRS: /usr/local/opt/openssl/include
-- OPENSSL_LIBRARIES: /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib
-- OPENSSL_VERSION: 1.0.2p
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ravi.gupta/learning/solver-app/others/Restweb
ravi-mac:Restweb ravi.gupta$ make
[ 33%] Building CXX object CMakeFiles/restserver.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/restserver.dir/src/handler.cpp.o
[100%] Linking CXX executable Build/bin/restserver
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Build/bin/restserver] Error 1
make[1]: *** [CMakeFiles/restserver.dir/all] Error 2
make: *** [all] Error 2
HI @kravigupta , is openssl installed on your system, brew install openssl
. Please try once again after installing openssl and do let me know.
Hi @Meenapintu, Openssl is installed already. I did install it using brew. From the output of cmake, you can see that the openssl is found.
Also, here is brew info for openssl -
brew ravi-mac:~ ravi.gupta$ brew info openssl
openssl: stable 1.0.2p (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
Hi @Meenapintu, Openssl is installed already. I did install it using brew. From the output of cmake, you can see that the openssl is found.
Also, here is brew info for openssl -
brew ravi-mac:~ ravi.gupta$ brew info openssl
openssl: stable 1.0.2p (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
okay, then I'll check once on my system tonight. but it's a problem related to crypto lib linking on mac. until then try to compile another small program that require crypto library linking. openssl isn't installed properly, or broken by system updates.
/
Hi @kravigupta
I've compiled it on my pc and there is no problem , current MacOS sierra.
Library not found for -lcrypto , I think you need to set system path for crypto linker.
Other threads https://stackoverflow.com/questions/26430432/ld-library-not-found like this may help.
Hi @Meenapintu , Thanks for help and sorry for not being able to respond early.
It worked fine. I did in different way. I skipped adding boost libraries at system level and included source in my project. Also, had to make changes to make file.
Your makefile and code is fine since it worked perfectly on centos.
Thanks for the repo.
Hi @kravigupta , Thank you for providing valuable feedback and debugging steps you have used .
It'll be helpful to somebody who faces problem with boost libs.
Your makefile and code is fine since it worked perfectly on centos. Yeah it's tested for all 3 environments ( unix, linux, and windows ( with visual studio ))
_ suggestions, improvements are always welcomed._