Linux arm 安装库交叉编译记录

Linux arm 安装库交叉编译记录

    • 1. openssl
      • 获取源码:
      • 下载源码到本地
      • 解压到本地
        • 制作makefile
        • 编译和安装
    • 2. mosquitto
      • 源码
      • 下载到本地
      • 修改makefile配置文件config.mk
        • 指定openssl路径
        • 指定安装路径
        • 指定编译链
      • 编译
    • 3. jansson
      • 源码
      • 编译
    • 4. gzip
      • 源码
    • 5. tar
      • 源码
    • 6. wget
      • 源码
      • 编译
    • 7. curl
    • 8. dropbear
      • 介绍
      • 源码
      • 编译
      • 移植
      • 启动

1. openssl

获取源码:

github: https://github.com/openssl/openssl
openssl官网:https://www.openssl.org/source/

下载源码到本地

wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz

解压到本地

制作makefile

添加shared表示编译成动态库
./config no-asm shared no-async --prefix=安装路径 --cross-compile-prefix=编译链
如:
./config no-asm shared no-async --prefix=/opt/work/Release/arm/ec20/openssl/openssl-1.1.1f --cross-compile-prefix=/opt/CrossComplie/ql-ol-sdk/ql-ol-crosstool/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-

注:如果arm是32位系统, 先删除makefile中的 -m64 编译选项

如果是直接安装到本地
./config no-asm shared --prefix=/home/openssl

编译和安装

make
make install

2. mosquitto

源码

http://mosquitto.org/files/source/

下载到本地

wget http://mosquitto.org/files/source/mosquitto-1.6.10.tar.gz

修改makefile配置文件config.mk

指定openssl路径
  1. 需要先编译openssl,参考(1. openssl)
  2. 在config.mk中添加:
    CFLAGS += -Iopenssl路径/include
    LDFLAGS += -Lopenssl路径/lib -lssl -lcrypto
    如:
    CFLAGS += -I/home/openssl/1.1.0/include
    LDFLAGS += -L/home/openssl/1.1.0/lib -lssl -lcrypto
指定安装路径

修改prefix?=的指向, 如:
prefix?=/home/mosquitto/1.6.10

指定编译链

在文档最后添加
CROSS_COMPILE=编译链路径
CC=gcc
CXX=g++

编译

make
make install

3. jansson

源码

http://digip.org/jansson/releases/

编译

configure中修改和添加
cross_compiling=yes
CC=/opt/CrossComplie/ql-ol-sdk/ql-ol-crosstool/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc

https://blog.csdn.net/u014029448/article/details/90118535

4. gzip

源码

https://ftp.gnu.org/gnu/gzip/

5. tar

源码

https://ftp.gnu.org/gnu/tar/

6. wget

源码

https://ftp.gnu.org/gnu/wget/

编译

如果使用下载https连接, 需要添加ssl选项, 这里使用的是openssl。
编译选项:
–with-libssl-prefix=openssl路径
–with-openssl=openssl路径
–with-ssl=openssl

./configure --host=arm-oe-linux-gnueabi --without-zlib --with-ssl=openssl --with-libssl-prefix=/opt/work/Release/arm/ec20/openssl/openssl-1.1.1h --with-openssl=/opt/work/Release/arm/ec20/openssl/openssl-1.1.1h CC=/opt/CrossComplie/ql-ol-sdk/ql-ol-crosstool/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc --prefix=/opt/work/Release/arm/ec20/wget/wget-1.19.1_openssl-1.1.1h

7. curl

https://curl.haxx.se/download.html

8. dropbear

介绍

  一个轻量级的SSH服务工具,常常用于嵌入式系统。

源码

https://matt.ucc.asn.au/dropbear/dropbear.html

编译

# 下载源码
$ wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2

# 解压
$ tar -jxvf dropbear-2020.81.tar.bz2
$ ls
dropbear-2020.81  dropbear-2020.81.tar.bz2
$ cd dropbear-2020.81
# 查看编译帮助文档
$ ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-static         Build static binaries
  --disable-harden        Don't set hardened build flags
  --disable-largefile     omit support for large files
  --disable-zlib          Don't include zlib support
  --enable-pam            Try to include PAM support
  --disable-openpty       Don't use openpty, use alternative method
  --disable-syslog        Don't include syslog support
  --disable-shadow        Don't use shadow passwords (if available)
  --enable-plugin         Enable support for External Public Key Authentication plug-in
  --enable-fuzz           Build fuzzing. Not recommended for deployment.
  --enable-bundled-libtom       Force using bundled libtomcrypt/libtommath even if a system version exists.
  --disable-bundled-libtom      Force using system libtomcrypt/libtommath, fail if it does not exist.
                                Default is to use system if available, otherwise bundled.
                                Dropbear requires system libtommath >= 1.2.0 and libtomcrypt >= 1.18.0
  --disable-lastlog       Disable use of lastlog even if detected no
  --disable-utmp          Disable use of utmp even if detected no
  --disable-utmpx         Disable use of utmpx even if detected no
  --disable-wtmp          Disable use of wtmp even if detected no
  --disable-wtmpx         Disable use of wtmpx even if detected no
  --disable-loginfunc     Disable use of login() etc. no
  --disable-pututline     Disable use of pututline() etc. (uwtmp) no
  --disable-pututxline    Disable use of pututxline() etc. (uwtmpx) no

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-zlib=PATH        Use zlib in PATH
  --with-pam=PATH        Use pam in PATH
  --with-lastlog=FILE|DIR specify lastlog location common locations

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.

# 配置
# configure --prefix=安装路径 --host=arm CC=交叉编译链gcc名称
# 安装路径最后使用绝对路径
$ ./configure --prefix=/opt/dropbear/install --host=arm CC=arm-linux-gcc

# 编译 
$ make
$ make install

移植

  将/opt/dropbear/install目录下的文件复制到嵌入式系统的/usr/bin,/usr/sbin下面
/opt/dropbear/install => /usr/bin,/usr/sbin
  注意,在/etc/目录下创建dropbear目录,这一个目录一定要创建,不然client连接不上ssh

mkdir -p /etc/dropbear

启动

/usr/sbin/dropbear -R

启动之后使用putty进行连接测试,可以正常访问,但是不能上下载文件。这是因为没有编译scp, 同时还需要zlib的支持,更详细的编译参考:嵌入式linux轻量级sshd服务工具Dropbear移植

你可能感兴趣的:(linux)