当前位置: 首页 > 工具软件 > HashDB > 使用案例 >

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

白青青
2023-12-01

在按照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即可安装。

 类似资料: