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

Linux ubuntu 编译安装boringssl

水铭晨
2023-12-01

参考 boringssl 根目录下的BUILDING.md 安装相关编译依赖项

## Build Prerequisites

  * [CMake](https://cmake.org/download/) 2.8.11 or later is required.

  * Perl 5.6.1 or later is required. On Windows,
    [Active State Perl](http://www.activestate.com/activeperl/) has been
    reported to work, as has MSYS Perl.
    [Strawberry Perl](http://strawberryperl.com/) also works but it adds GCC
    to `PATH`, which can confuse some build tools when identifying the compiler
    (removing `C:\Strawberry\c\bin` from `PATH` should resolve any problems).
    If Perl is not found by CMake, it may be configured explicitly by setting
    `PERL_EXECUTABLE`.

  * On Windows you currently must use [Ninja](https://ninja-build.org/)
    to build; on other platforms, it is not required, but recommended, because
    it makes builds faster.

  * If you need to build Ninja from source, then a recent version of
    [Python](https://www.python.org/downloads/) is required (Python 2.7.5 works).

  * On Windows only, [Yasm](http://yasm.tortall.net/) is required. If not found
    by CMake, it may be configured explicitly by setting
    `CMAKE_ASM_NASM_COMPILER`.

  * A C compiler is required. On Windows, MSVC 14 (Visual Studio 2015) or later
    with Platform SDK 8.1 or later are supported. Recent versions of GCC (4.8+)
    and Clang should work on non-Windows platforms, and maybe on Windows too.
    To build the tests, you also need a C++ compiler with C++11 support.

  * [Go](https://golang.org/dl/) is required. If not found by CMake, the go
    executable may be configured explicitly by setting `GO_EXECUTABLE`.

  * To build the x86 and x86\_64 assembly, your assembler must support AVX2
    instructions and MOVBE. If using GNU binutils, you must have 2.22 or later.

修改boringssl 根目录下的CMakeLists.txt:

对所有的 CMAKE_C_FLAGS 和 CMAKE_CXX_FLAGS 像如下添加 -g3, 生成有调试信息的库文件:

set(CMAKE_C_FLAGS   "-g3 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
set(CMAKE_CXX_FLAGS "-g3 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")

## Building

Using Make (does not work on Windows):

    mkdir build
    cd build
    cmake ..
    make
 

在build目录下分别生成如下库文件:

build/crypto/libcrypto.a

build/ssl/libssl.a

在build 目录下执行如下命令, 将库文件安装到系统:

$sudo cp ./crypto/libcrypto.a /usr/local/lib/
$sudo cp ./ssl/libssl.a /usr/local/lib/

在boringssl 根目录下执行如下命令,将头文件安装到系统:

$sudo cp include/openssl/* /usr/local/include/openssl/

从新编译应用程序

 类似资料: