MasOS 安装 hashdb 报错 fatal error: ‘openssl/evp.h‘ file not found 的解决方案

在按照Wiki的指示安装时报错fatal error: 'openssl/evp.h' file not found,按照wiki的解决方案执行

brew link openssl --force

但是brew却拒绝链接,即使加了--force仍然失败,推测是新版brew针对ssl进行了保护,以免强制链接后其他程序出错。
于是只好另辟蹊径,手动对头文件建立链接如下

sudo mkdir /usr/include/openssl
sudo ln /usr/local/opt/openssl/include/openssl/* /usr/include/openssl/

重新执行./configure && make,此时应该会报错如下

/bin/sh ../libtool  --tag=CXX   --mode=link g++ -Wall -MD -D_FORTIFY_SOURCE=2 -Wpointer-arith -Wshadow -Wwrite-strings -Wcast-align -Wredundant-decls -Wdisabled-optimization -Wfloat-equal -Wmultichar -Wmissing-noreturn -Woverloaded-virtual -Wsign-promo -funit-at-a-time -Weffc++ -g -D_THREAD_SAFE -D_THREAD_SAFE -pthread -g -O3 -std=c++11  -D_FORTIFY_SOURCE=2  -static -L/usr/local/lib -o hashdb export_json.o import_json.o import_tab.o main.o scan_list.o ../src_libhashdb/libhashdb.la -lstdc++ -lbz2 -lewf -lssl -lcrypto -lz  -lpthread 
libtool: link: g++ -Wall -MD -D_FORTIFY_SOURCE=2 -Wpointer-arith -Wshadow -Wwrite-strings -Wcast-align -Wredundant-decls -Wdisabled-optimization -Wfloat-equal -Wmultichar -Wmissing-noreturn -Woverloaded-virtual -Wsign-promo -funit-at-a-time -Weffc++ -g -D_THREAD_SAFE -D_THREAD_SAFE -pthread -g -O3 -std=c++11 -D_FORTIFY_SOURCE=2 -o hashdb export_json.o import_json.o import_tab.o main.o scan_list.o -Wl,-bind_at_load  -L/usr/local/lib ../src_libhashdb/.libs/libhashdb.a -lstdc++ -lbz2 -lewf -lssl -lcrypto -lz -lpthread -pthread
Undefined symbols for architecture x86_64:
  "_EVP_MD_CTX_free", referenced from:
      hashdb::ingest_file(hasher::file_reader_t const&, hashdb::import_manager_t&, hasher::ingest_tracker_t&, hashdb::scan_manager_t const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, unsigned long, bool, bool, bool, hasher::job_queue_t*) in libhashdb.a(ingest.o)
      hasher::process_job(hasher::job_t const&) in libhashdb.a(process_job.o)
      hasher::recurse(hasher::job_t const&, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char const*, unsigned long) in libhashdb.a(process_recursive.o)
  "_EVP_MD_CTX_new", referenced from:
      hashdb::ingest_file(hasher::file_reader_t const&, hashdb::import_manager_t&, hasher::ingest_tracker_t&, hashdb::scan_manager_t const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, unsigned long, bool, bool, bool, hasher::job_queue_t*) in libhashdb.a(ingest.o)
      hasher::process_job(hasher::job_t const&) in libhashdb.a(process_job.o)
      hasher::recurse(hasher::job_t const&, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char const*, unsigned long) in libhashdb.a(process_recursive.o)
  "_EVP_MD_CTX_reset", referenced from:
      hashdb::ingest_file(hasher::file_reader_t const&, hashdb::import_manager_t&, hasher::ingest_tracker_t&, hashdb::scan_manager_t const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, unsigned long, bool, bool, bool, hasher::job_queue_t*) in libhashdb.a(ingest.o)
      hasher::hash_calculator_t::calculate(unsigned char const*, unsigned long, unsigned long, unsigned long) in libhashdb.a(process_job.o)
      hasher::hash_calculator_t::calculate(unsigned char const*, unsigned long, unsigned long, unsigned long) in libhashdb.a(process_recursive.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [hashdb] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

这其实是编译的最后一条命令,对所有obj及库进行了链接。显然,由于我们只增加了头文件,并没有改动MacOS原来的ssl库,由于版本不兼容而链接失败。此时只需手动运行这条编译命令,将-L参数改为新的ssl库路径即可

cd ./src
/bin/sh ../libtool  --tag=CXX   --mode=link g++ -Wall -MD -D_FORTIFY_SOURCE=2 -Wpointer-arith -Wshadow -Wwrite-strings -Wcast-align -Wredundant-decls -Wdisabled-optimization -Wfloat-equal -Wmultichar -Wmissing-noreturn -Woverloaded-virtual -Wsign-promo -funit-at-a-time -Weffc++ -g -D_THREAD_SAFE -D_THREAD_SAFE -pthread -g -O3 -std=c++11  -D_FORTIFY_SOURCE=2  -static -L/usr/local/opt/openssl/lib/ -o hashdb export_json.o import_json.o import_tab.o main.o scan_list.o ../src_libhashdb/libhashdb.la -lstdc++ -lbz2 -lewf -lssl -lcrypto -lz  -lpthread
cd ..
make

此时应当已经编译成功。执行make install即可安装。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值