zoukankan      html  css  js  c++  java
  • Sqlite,libevent,openssl,mosquito交叉编译

    一、设置交叉编译环境

    1. 在makefile所在目录(或源代码根目录)打开终端。
    2. 在终端中设置交叉编译所需的临时环境变量(也可写到配置文件中设置为全局环境变量),其中交叉编译工具链的名称和目录需要根据实际目录设置,每次编译前执行以下命令:
    export CC=/home/hk/Desktop/sixin/gcc-4.9/bin/mips-linux-gcc  
    export CXX=/home/hk/Desktop/sixin/gcc-4.9/bin/mips-linux-g++
    export AR=/home/hk/Desktop/sixin/gcc-4.9/bin/mips-linux-ar
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hk/Desktop/sixin/gcc-4.9/lib
    

    二、交叉编译sqlite3

    1.设置交叉编译环境。

    2.执行以下命令配置编译选项。 --prefix= 后面跟的是编译出来的库的安装目录,需要根据实际情况设置,--host= 后面的内容根据交叉编译工具设置。

    ./configure --host=arm-linux-gnueabihf --prefix=/home/hk/Desktop/moxa/sqlite-autoconf-3071600/out
    
    make   #编译
    make install #安装
    

    三、交叉编译openssl

    1.设置交叉编译环境。

    2.执行以下命令配置编译选项。 --prefix= 后面跟的是编译出来的库的安装目录,需要根据实际情况设置。

    • 编译静态库,linux:'arm-linux-gnueabihf-gcc'arm-linux-gnueabihf-gcc根据交叉编译工具设置。

      ./Configure linux-elf-arm -DB_ENDIAN linux:'arm-linux-gnueabihf-gcc'  --prefix=[输出路径]
      make
      make install
      
    • 编译动态库

    ./config -fPIC no-asm -shared --prefix=/home/hk/Desktop/openssl-1.0.0/out
    
    # 配置完成之后需要修改makefile,将makefile中的 -m64 删除。
    make
    make install
    

    注意:尽量使用静态库,动态库有时会出错。

    四、交叉编译libevent

    1.设置交叉编译环境。

    2.执行以下命令配置编译选项。 --prefix= 后面跟的是编译出来的库的安装目录,需要根据实际情况设置。

    3.CPPFLAGS="-I/usr/local/Cellar/openssl/1.0.2h_1/include" 为openssl头文件目录,LDFLAGS=LDFLAGS="-L/usr/local/Cellar/openssl/1.0.2h_1/lib -lssl -lcrypto"是编译出来的openssl库目录,需要根据实际情况设置。

    ./configure --host=arm-linux CPPFLAGS="-I/usr/local/Cellar/openssl/1.0.2h_1/include" LDFLAGS="-L/usr/local/Cellar/openssl/1.0.2h_1/lib -lssl -lcrypto"  --prefix=/usr/local
    
    make 
    make install
    

    五、交叉编译 paho.mqtt.c ,需要先交叉编译 openssl

    1.设置交叉编译环境。

    2.修改makefile ,在129行添加如下,CFLAGS += -I后面的内容为openssl头文件目录,LDFLAGS += -L是编译出来的openssl库目录,需要根据实际情况设置。

    # 修改makefile ,在129行添加如下, -I参数后面的内容为 交叉编译openssl库安装目录
    CFLAGS += -I./../openssl-1.1.0g/install/include
    LDFLAGS += -L./../openssl-1.1.0g/install/lib
    
    #修改后执行make命令编译
    make
    

    3.编译完成后,会在当前目录创建build目录,进入build目录,里面有一个output目录和一个版本头文件,output目录中存放着编译出来的库文件,examples和测试程序。

    六、交叉编译 mosquitto

    1. 设置交叉编译环境。
    2. 修改源文件目录下的 config.mk文件。
      • WITH_TLS、WITH_TLS_PSK、WITH_SRV、WITH_UUID 、WITH_DOCS设置为 no
      • 在文件头部设置依赖的paho.mqtt.copenssl头文件和库目录,如下所示:
    #  -I参数后面的内容为paho.mqtt.c库和openssl头文件目录,-L参数后面的内容为编译好的paho.mqtt.c库和openssl库目录 ,注意: 实际修改时需要不使用[]。
    CFLAGS += -I[paho.mqtt.c源代码目录下的src目录] -I[openssl头文件目录]
    LDFLAGS += -L[编译处的paho.mqtt.c库目录]    -L[编译出来的openssl库目录] -lssl -lcrypto 
    
  • 相关阅读:
    UVa 10118 记忆化搜索 Free Candies
    CodeForces 568B DP Symmetric and Transitive
    UVa 11695 树的直径 Flight Planning
    UVa 10934 DP Dropping water balloons
    CodeForces 543D 树形DP Road Improvement
    CodeForces 570E DP Pig and Palindromes
    HDU 5396 区间DP 数学 Expression
    HDU 5402 模拟 构造 Travelling Salesman Problem
    HDU 5399 数学 Too Simple
    CodeForces 567F DP Mausoleum
  • 原文地址:https://www.cnblogs.com/ay-a/p/10459065.html
Copyright © 2011-2022 走看看