首页 > 解决方案 > OpenWall bcrypt 库集成

问题描述

我在我的项目中集成 OpenWall bcrypt 库时遇到问题,无论是在 linux 上还是在 windows 上。

这是我所做的:

  1. 从https://www.openwall.com/crypt下载了库
  2. 执行 makefile 以生成 .o 文件
  3. 在我的编译命令行中包含这些文件(请参阅下面的 bash 文件)
  4. 在我的源代码中添加了#include "ow-crypt.h"
  5. 尝试使用函数 crypt_gensalt
  6. 出现链接错误

我的 bash 文件用于编译:

project_root=/home/ubuntu/lamodal-dev

lws_lib_dir_path=/usr/local/lib
libxml_include_dir_path=/usr/include/libxml2
lws_lib_name=websockets
libxml_lib_name=xml2
sqlite3_lib_name=sqlite3

debug_compile_flags="\
-g \
-Wall \
-Wno-unused-variable \
-Wno-unused-but-set-variable \
-Wno-unused-result"

g++ -pthread -std=c++11 $debug_compile_flags \
-I$libxml_include_dir_path \
-L$lws_lib_dir_path \
$project_root/code/third/openwall/bcrypt/crypt_blowfish.o \
$project_root/code/third/openwall/bcrypt/crypt_gensalt.o \
$project_root/code/third/openwall/bcrypt/wrapper.o \
$project_root/code/third/openwall/bcrypt/x86.o \
../../code/lamodal-dev.cpp \
-l$lws_lib_name \
-l$libxml_lib_name \
-l$sqlite3_lib_name \
-lcrypt \
-o ../../bin/linux/lamodal-dev.run

输出:

undefined reference to `crypt_gensalt(char const*, unsigned long, char const*, int)'

我不应该链接什么?

标签: cbcrypt

解决方案


推荐阅读