arm-none-linux-gnueabi-gcc 컴파일 표준 라이브러리 인용

8752 단어
arm-none-linux-gnueabi-gcc로 컴파일할 때 표준 라이브러리에서 찾을 수 없는 상황이 발생합니다.예:
[root@localhost wpcode]# arm-none-linux-gnueabi-gcc *.c -fPIC -shared -o libsdk.so  opensslRsa.c:3:30: error: openssl/ossl_typ.h: No such file or directory opensslRsa.c:4:25: error: openssl/pem.h: No such file or directory opensslRsa.c:5:26: error: openssl/x509.h: No such file or directory opensslRsa.c:6:25: error: openssl/rsa.h: No such file or directory opensslRsa.c:8:26: error: openssl/des.h: No such file or directory
 
해결 방법:
[root@localhost wpcode]# echo 'main(){}'|arm-linux-gcc -E -v - 
bash: arm-linux-gcc:  ...
[root@localhost wpcode]# echo 'main(){}'|arm-none-linux-gnueabi-gcc -E -V -
arm-none-linux-gnueabi-gcc: '-V' must come at the start of the command line
[root@localhost wpcode]# echo 'main(){}'|arm-none-linux-gnueabi-gcc -E -v -
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q1-203' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) 
COLLECT_GCC_OPTIONS='-E' '-v' '-funwind-tables'
 /usr/local/arm-2009q1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.3.3/cc1 -E -quiet -v -iprefix /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/ -isysroot /usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc - -funwind-tables
ignoring nonexistent directory "/usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/usr/local/include"
ignoring duplicate directory "/usr/local/arm-2009q1/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.3/include"
ignoring duplicate directory "/usr/local/arm-2009q1/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.3/include-fixed"
ignoring duplicate directory "/usr/local/arm-2009q1/bin/../lib/gcc/../../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include
 /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include-fixed
 /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/include
 /usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/usr/include
End of search list.
# 1 ""
# 1 ""
# 1 ""
# 1 ""
main(){}
COMPILER_PATH=/usr/local/arm-2009q1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.3.3/:/usr/local/arm-2009q1/bin/../libexec/gcc/:/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/
LIBRARY_PATH=/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/:/usr/local/arm-2009q1/bin/../lib/gcc/:/usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/lib/:/usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/lib/:/usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-funwind-tables'

우리는 그의 표준 라이브러리의 컴파일 경로를 찾을 수 있다.
#include <...> search starts here:  /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include  /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include-fixed  /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/include  /usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/usr/include
두 번째 단계: 우리가 가지고 있는 표준 라이브러리의 경로를 표준 라이브러리 주소로 찾습니다
[root@localhost wpcode]# find / -name pem.h
/usr/local/src/mysql-5.6.35/extra/yassl/include/openssl/pem.h
/usr/local/src/openssl-1.1.0e/include/openssl/pem.h
/usr/local/openssl/include/openssl/pem.h
[root@localhost wpcode]# 

3단계: 연결 주소 설정
[root@localhost wpcode]# ln -s/usr/local/openssl/include/openssl/usr/local/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/usr/include/openssl
자, 다시 컴파일하여 ARM의 동적 라이브러리 파일 생성
[root@localhost wpcode]# arm-none-linux-gnueabi-gcc *.c -fPIC -shared -o libsdk.so 
sdklib.c: In function 'qrcode_verify':
sdklib.c:484: warning: passing argument 4 of 'get_grcode_all_elements' from incompatible pointer type
sdklib.c:484: warning: passing argument 5 of 'get_grcode_all_elements' from incompatible pointer type
sdklib.c:546: warning: passing argument 2 of 'read_data_file' from incompatible pointer type
sdklib.c:549: warning: passing argument 1 of 'getMac' from incompatible pointer type
sdklib.c:549: warning: passing argument 2 of 'getMac' from incompatible pointer type
sdklib.c:549: warning: passing argument 3 of 'getMac' from incompatible pointer type
sdklib.c:673: warning: passing argument 1 of 'getMac' from incompatible pointer type
sdklib.c:673: warning: passing argument 2 of 'getMac' from incompatible pointer type
sdklib.c:673: warning: passing argument 3 of 'getMac' from incompatible pointer type
WriteLog.c: In function 'WRITE_LOG':
WriteLog.c:88: warning: passing argument 2 of 'WriteLogFile' discards qualifiers from pointer target type
WriteLog.c: In function 'GetTime':
WriteLog.c:238: warning: incompatible implicit declaration of built-in function 'strncpy'
WriteLog.c: In function 'get_save_file_name':
WriteLog.c:264: warning: incompatible implicit declaration of built-in function 'strncpy'
WriteLog.c: In function 'GetCompletePath':
WriteLog.c:310: warning: incompatible implicit declaration of built-in function 'strcat'
WriteLog.c:311: warning: incompatible implicit declaration of built-in function 'strncpy'
WriteLog.c:311: warning: incompatible implicit declaration of built-in function 'strlen'
WriteLog.c: In function 'GetConfigValue':
WriteLog.c:338: warning: passing argument 1 of 'get_save_file_name' from incompatible pointer type
WriteLog.c: In function 'GetStringContentValue':
WriteLog.c:379: warning: incompatible implicit declaration of built-in function 'strcpy'
WriteLog.c:383: warning: incompatible implicit declaration of built-in function 'memset'
WriteLog.c:393: warning: incompatible implicit declaration of built-in function 'strlen'
WriteLog.c:407: warning: incompatible implicit declaration of built-in function 'memcpy'
WriteLog.c:449: warning: incompatible implicit declaration of built-in function 'strncpy'
WriteLog.c: In function 'GetConfigFileStringValue':
WriteLog.c:492: warning: incompatible implicit declaration of built-in function 'strcpy'
WriteLog.c:496: warning: incompatible implicit declaration of built-in function 'strcpy'
[root@localhost wpcode]# ls
Config.ini  mackey      Makefile      opensslRsa.h  publickey      sdk.h     sdklib.o      test    test.o                   WriteLog.c  WriteLog.o
libsdk.so   mackey.txt  opensslRsa.c  opensslRsa.o  publickey.pem  sdklib.c  signdata.txt  test.c  WriteLog-2018-11-07.log  WriteLog.h
[root@localhost wpcode]# 
[root@localhost wpcode]# file libsdk.so 
libsdk.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped
[root@localhost wpcode]# 

좋은 웹페이지 즐겨찾기