qq_28351465
Zpeg
2016-08-19 04:04
采纳率: 100%
浏览 8.4k
已采纳

Linux 下openssl交叉编译出错

make时出错:
报错内容:cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
In file included from cryptlib.h:62:0,
from cryptlib.c:117:
/usr/include/stdlib.h:759:34: fatal error: bits/stdlib-bsearch.h: No such file or directory
compilation terminated.
make[1]: *** [cryptlib.o] Error 1
make: *** [build_crypto] Error 1

具体编译安装过程如下:

安装文件: openssl-1.0.2h.tar.gz

参考网址: http://blog.csdn.net/zy799894671/article/details/22289039

1、 arm-config.sh :

./config no-asm shared --prefix=/usr/local/arm-openssl  

      解决1:./config no-asm shared --prefix=/usr/local/arm-openssl --host=arm-xilinx-linux-gnueabi 

      解决4:CC=arm-xilinx-linux-gnueabi-gcc ./config no-asm shared --prefix=/usr/local/arm-openssl

2、修改MakeFile:

#CC= gcc
CC= arm-xilinx-linux-gnueabi-gcc
#CFLAG= -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=pentium -DL_ENDIAN -O3 -fomit-frame-pointer -Wall
CFLAG= -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_N -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS
PEX_LIBS=
EX_LIBS= -ldl
EXE_EXT=
ARFLAGS=
#AR= ar $(ARFLAGS) r
AR= arm-xilinx-linux-gnueabi-ar $(ARFLAGS) r
#RANLIB= /usr/bin/ranlib
RANLIB= arm-xilinx-linux-gnueabi-ranlib
#NM= nm
NM= arm-xilinx-linux-gnueabi-nm
PERL= /usr/bin/perl
TAR= tar
TARFLAGS= --no-recursion
#MAKEDEPPROG= gcc
MAKEDEPPROG= arm-xilinx-linux-gnueabi-gcc
LIBDIR=lib

make depend后出现错误:

cc1: error: include location "/usr/include" is unsafe for cross-compilation [-Werror=poison-system-directories]
cc1: all warnings being treated as errors

错误分析原因:

这种错误在网上有两种可能:

1、不能交叉编译到默认目录下,需要编译到单独的文件夹中(之前已经那么做了)

2、依赖库需要先交叉编译,这里错误目录是"/usr/include" 故也不是这个问题。

错误解决尝试1:

将配置后增加--host=arm-xilinx-linux-gnueabi ,详看1点

然后修改 makefile

错误不变

错误解决尝试2:

1步骤后 增加一步 # ./config -t

错误不变

错误尝试解决3

2步骤 多修改Makefile文件一处

#PLATFORM=linux-elf
PLATFORM=arm-xilinx-linux-gnueabi

错误不变

错误尝试解决4

1步骤 将arm-config.sh前增加为:CC=arm-xilinx-linux-gnueabi-gcc

错误不变

错误尝试解决5

增加arm的环境变量

export ARCH=arm
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
错误不变

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • qq_28351465
    Zpeg 2016-08-19 07:00
    已采纳

    已解决:
    错误尝试解决6
    将环境变量中之前加的
    export PATH=$PATH:/usr/local/ffmpeg3.0/bin:/usr/local/ssl/bin:/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/lib:/usr/local/ffmpeg3.0/lib:/home/zrb/SatelliteAV/AES/LocoDrmSdk/3rd/libs/stlinux:/usr/local/ssl/lib
    export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/include:/usr/local/ffmpeg3.0/include:/home/zrb/SatelliteAV/AES/LocoDrmSdk/3rd/include/stlinux:/usr/local/ssl/include/openssl
    export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include:/usr/local/ffmpeg3.0/include:/home/zrb/SatelliteAV/AES/LocoDrmSdk/3rd/include/stlinux:/usr/local/ssl/include/openssl
    删除 改成:
    export ARCH=arm
    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    export PATH=$PATH:/usr/local/ffmpeg3.0/bin:/usr/local/ssl/bin:/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin
    错误得解
    看来错误原因是 之前环境变量配置了linux下的库,再换成arm的编译的时候 引用到了之前的库 故出错

    点赞 评论
  • oyljerry
    oyljerry 2016-08-19 06:05

    关键是没有找到这个文件

    /usr/include/stdlib.h:759:34: fatal error: bits/stdlib-bsearch.h: No such file or directory

    点赞 评论

相关推荐