Linux ubuntu 编译安装boringssl

本文详细介绍了BoringSSL的编译与安装过程,包括必要的编译依赖项如CMake、Perl、Ninja、Python、Yasm、Go等,并提供了在Windows和其他平台上的具体配置建议。此外,还讲解了如何生成带调试信息的库文件,以及如何将生成的库文件和头文件安装到系统中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考 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/

从新编译应用程序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值