libzip Linux 크로스 컴파일 구성

libzip Linux 크로스 컴파일 구성

크로스컴파일을 하려고 하는데libzip-1.5.1이전에 성공적으로 준수함zlib-1.2.11(이것은 libzip에 필요하며 로컬 홈 경로에 설치되어 있습니다.) cmake 프로세스에 문제가 있습니다.

빌드 및 컴파일(빌드 디렉터리에서 libzip의 소스 폴더까지)에 사용하는 스크립트는 다음과 같습니다.

#!/bin/sh

PREFIX=${PWD}/install
CCPATH=/opt/arm64/gcc-linaro-6.3.1-2017.02-rc2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf
ZLIBPATH=${PWD}/../../zlib-1.2.11/

# here is where zlib is installed
# ZLIBINSTALLEDPATH contains include, lib, share directories
ZLIBINSTALLEDPATH=${ZLIBPATH}/build_armhf64/install/

export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${ZLIBINSTALLEDPATH}/lib/pkgconfig/"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ZLIBINSTALLEDPATH}/lib/"
export CMAKE_AR=${CCPATH}-ar
export CC=${CCPATH}-gcc
export CXX=${CCPATH}-g++
export CMAKE_LINKER=${CCPATH}-ld
export CMAKE_RANLIB=${CCPATH}-ranlib
export CMAKE_OBJDUMP=${CCPATH}-objdump
export CMAKE_OBJCOPY=${CCPATH}-objcopy
export CMAKE_STRIP=${CCPATH}-strip
#export CMAKE_READELF=${CCPREFIX}-readelf
export CMAKE_NM=${CCPATH}-nm

cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} \
    -DZLIB_INCLUDE_DIR=${ZLIBINSTALLEDPATH}/include/  \
    -DZLIB_LIBRARY=${ZLIBINSTALLEDPATH}/lib/  \
     ../
make -j 8

그러나 빌드 프로세스의 94%에서 다음 오류가 발생합니다.

[ 92%] Building C object regress/CMakeFiles/tryopen.dir/tryopen.c.o
[ 94%] Building C object src/CMakeFiles/zipcmp.dir/zipcmp.c.o
[ 94%] Linking C executable add_from_filep
[ 94%] Linking C executable fopen_unchanged
[ 94%] Linking C executable tryopen
[ 94%] Building C object regress/CMakeFiles/hole.dir/source_hole.c.o
[ 94%] Linking C executable zipmerge
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
regress/CMakeFiles/add_from_filep.dir/build.make:95: recipe for target 'regress/add_from_filep' failed
make[2]: *** [regress/add_from_filep] Error 1
CMakeFiles/Makefile2:726: recipe for target 'regress/CMakeFiles/add_from_filep.dir/all' failed
make[1]: *** [regress/CMakeFiles/add_from_filep.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
regress/CMakeFiles/tryopen.dir/build.make:95: recipe for target 'regress/tryopen' failed
make[2]: *** [regress/tryopen] Error 1
CMakeFiles/Makefile2:800: recipe for target 'regress/CMakeFiles/tryopen.dir/all' failed
make[1]: *** [regress/CMakeFiles/tryopen.dir/all] Error 2
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
regress/CMakeFiles/fopen_unchanged.dir/build.make:95: recipe for target 'regress/fopen_unchanged' failed
make[2]: *** [regress/fopen_unchanged] Error 1
CMakeFiles/Makefile2:615: recipe for target 'regress/CMakeFiles/fopen_unchanged.dir/all' failed
make[1]: *** [regress/CMakeFiles/fopen_unchanged.dir/all] Error 2
[ 94%] Building C object regress/CMakeFiles/ziptool_regress.dir/source_hole.c.o
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
src/CMakeFiles/zipmerge.dir/build.make:95: recipe for target 'src/zipmerge' failed
make[2]: *** [src/zipmerge] Error 1
CMakeFiles/Makefile2:432: recipe for target 'src/CMakeFiles/zipmerge.dir/all' failed
make[1]: *** [src/CMakeFiles/zipmerge.dir/all] Error 2
[ 94%] Linking C executable zipcmp
[ 94%] Linking C executable ziptool
[ 96%] Linking C executable hole
CMakeFiles/zipcmp.dir/zipcmp.c.o.:. /Inlib /functionlibzip.so.5.0 :` compute_crcundefined' :reference
 zipcmp.cto: (`.inflatetext'+
0x4a0.).:/ libundefined/ libzip.so.5.0reference:  toundefined  `referencecrc32 'to
 zipcmp.c`:crc32('.
text.+.0x53e/)lib:/ libzip.so.5.0undefined:  referenceundefined  toreference  `tocrc32 '`
zErrorCMakeFiles'/
zipcmp.dir./.zipcmp.c.o/:lib /Inlibzip.so.5.0 :function  undefined` test_filereference':
 zipcmp.cto: (`.deflatetext'+
0x1494.).:/ libundefined/ libzip.so.5.0reference:  toundefined  `referencecrc32'
zipcmp.c:(.text+0x14fe): undefined reference to `crc32'
.. /tolib /`libzip.so.5.0deflateInit2_:' 
undefined. .reference/ libto/ libzip.so.5.0`:inflate 'undefined
 .reference. /tolib /`libzip.so.5.0inflateEnd:' 
undefined. .reference/ libto/ libzip.so.5.0`:zError 'undefined
 .reference. /tolib /`libzip.so.5.0deflateEnd:' undefined reference to `deflate'
.
../.lib//liblibzip.so.5.0/:libzip.so.5.0 :undefined  undefinedreference  referenceto  to` deflateInit2_`'inflateInit2_
'.
./lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `collect2: error: ld returned 1 exit status
inflateInit2_'
collect2: error: ld returned 1 exit status
src/CMakeFiles/ziptool.dir/build.make:95: recipe for target 'src/ziptool' failed
make[2]: *** [src/ziptool] Error 1
src/CMakeFiles/zipcmp.dir/build.make:95: recipe for target 'src/zipcmp' failed
make[2]: *** [src/zipcmp] Error 1
CMakeFiles/Makefile2:469: recipe for target 'src/CMakeFiles/ziptool.dir/all' failed
make[1]: *** [src/CMakeFiles/ziptool.dir/all] Error 2
CMakeFiles/Makefile2:395: recipe for target 'src/CMakeFiles/zipcmp.dir/all' failed
make[1]: *** [src/CMakeFiles/zipcmp.dir/all] Error 2
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
[ 98%] Linking C executable ziptool_regress
regress/CMakeFiles/hole.dir/build.make:121: recipe for target 'regress/hole' failed
make[2]: *** [regress/hole] Error 1
CMakeFiles/Makefile2:652: recipe for target 'regress/CMakeFiles/hole.dir/all' failed
make[1]: *** [regress/CMakeFiles/hole.dir/all] Error 2
../lib/libzip.so.5.0: undefined reference to `inflate'
../lib/libzip.so.5.0: undefined reference to `crc32'
../lib/libzip.so.5.0: undefined reference to `zError'
../lib/libzip.so.5.0: undefined reference to `deflate'
../lib/libzip.so.5.0: undefined reference to `deflateInit2_'
../lib/libzip.so.5.0: undefined reference to `inflateEnd'
../lib/libzip.so.5.0: undefined reference to `deflateEnd'
../lib/libzip.so.5.0: undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
regress/CMakeFiles/ziptool_regress.dir/build.make:121: recipe for target 'regress/ziptool_regress' failed
make[2]: *** [regress/ziptool_regress] Error 1
CMakeFiles/Makefile2:689: recipe for target 'regress/CMakeFiles/ziptool_regress.dir/all' failed
make[1]: *** [regress/CMakeFiles/ziptool_regress.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

경로가 잘 구성되어 있는 것처럼 보임에도 불구하고 cmake가 컴파일된 zlib 라이브러리를 찾을 수 없는 것 같습니다.

libzip을 사용할 때 비슷한 문제가 발생한 사람이 있습니까? 이 문제를 해결할 수 있는 추가 cmake 매크로가 있습니까?

- - 갱신 - -

실제로 빌드 작업을 억제하는 이 오류를 제거했습니다.zipcmp, 압축 및 병합그리고압축 도구(필요하지 않기 때문에) 다음 줄을 주석 처리하십시오.

#ADD_EXECUTABLE(zipcmp zipcmp.c ${SRC_EXTRA_FILES})
#TARGET_LINK_LIBRARIES(zipcmp zip)
#INSTALL(TARGETS zipcmp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

#ADD_EXECUTABLE(zipmerge zipmerge.c ${SRC_EXTRA_FILES})
#TARGET_LINK_LIBRARIES(zipmerge zip)
#INSTALL(TARGETS zipmerge RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

#ADD_EXECUTABLE(ziptool ziptool.c ${SRC_EXTRA_FILES})
#TARGET_LINK_LIBRARIES(ziptool zip)
#INSTALL(TARGETS ziptool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

입력하다 src/CMakeLists.txt. 그런 다음 make -j 8 zip라이브러리를 사용 하고 컴파일했습니다 make install/fast. 여전히 오류를 반환합니다.

Install the project...
-- Install configuration: ""
-- Installing: /home/simo/adtdev/Var_libs/libzip-1.5.1/build_armhf64/install/lib/pkgconfig/libzip.pc
-- Installing: /home/simo/adtdev/Var_libs/libzip-1.5.1/build_armhf64/install/include/zipconf.h
-- Installing: /home/simo/adtdev/Var_libs/libzip-1.5.1/build_armhf64/install/include/zip.h
-- Installing: /home/simo/adtdev/Var_libs/libzip-1.5.1/build_armhf64/install/lib/libzip.a
CMake Error at man/cmake_install.cmake:36 (file):
  file INSTALL cannot find
  "/home/simo/adtdev/Var_libs/libzip-1.5.1/build_armhf64/man/ZIP_SOURCE_GET_ARGS.3".
Call Stack (most recent call first):
  cmake_install.cmake:46 (include)


Makefile:89: recipe for target 'install/fast' failed
make: *** [install/fast] Error 1

하지만 설치 디렉터리에 이미 라이브러리와 헤더가 설치되어 있고 그것이 필요한 것이기 때문에 신경 쓰지 않습니다.

답변1

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /your/toolchain/path/bin/yourcompile-gcc)
SET(CMAKE_CXX_COMPILER /your/toolchain/path/bin/yourcompile-g++)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  /your/rootfs/path)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

관련 정보