본문 바로가기
Development/Linux

[Linux] PDF 무료 소스 Poppler 빌드(Petalinux) 하기 (2)

by qWooWp 2022. 12. 1.
반응형

처음에는 Cross-toolchain 을 Ubuntu 에서 설정해서 빌드를 하려고 하였으나....

너무 많은 의존성과 오류 설정 문제로 인해서 ... 포기를 하고

(관련하여 하다만 설정 파일 샘플 예제가 필요하다면 이글 제일 마지막에 붙여 놓았습니다. )

 

Target Device 에 빌드 환경을 구성하였습니다.

이렇게 하면 장점은 별도의 cross compiler 를 위한  cmake 구성을 하지 않아도 됩니다.

 

즉 동일한 절차를 통해서 빌드가 가능한 장점이 있다...

mkdir build

cd build

 

cmake ../ -DENABLE_QT6=OFF -DENABLE_QT5=OFF -DTESTDATADIR=/home/dev/test -DPOPPLER_DATADIR=/home/dev/poppler-data-0.4.11

 

make

 

여기서 중간에 에러가 발생해서 poppler.so, poppler-glib 만 생성될 것이다.

여기서 make poppler-cpp 를 수행하면 이 모듈만 생성이 되어 진다.

 

하아.. 다 빌드도 못하고 원하는 것만 겨우 얻어 도망처 나오듯 나온 작업이었다 ㅠ.ㅠ;;

 

 

* 사전 고려 사항 c++ 로 빌드를 할 것이기 때문에 qt5 모듈은 필요가 없음.

 

이전 장에서 필요한 의존성 모듈과 관련 include 디렉토리의 파일들이 빌드를 위해 필요합니다.

이것들을 다 찾아서 Target Device 에 복사를 해줌.

so 파일은 마찬가지고 오픈소스를 가져와서 Target Device 에서 빌드를 하거나

petalinux-build -c 모듈명

을 이용하여 빌드한 파일을 복사 했습니다.

관련 내용은 아래 추가 참조.


FreeType Library 빌드

FREETYPE 라이브러리가 필요하므로 관련 소스를 다운로드 해 봅니다.

https://sourceforge.net/projects/freetype/files/

 

1. 소스코드를 Target Device에 복사를 한다.

2. 압출을 해제 한다

tar xvf ./freetype….

3. 환경설정 스크립트를 수행한다.

# ./configure

#  make 수행


gperf 빌드

FontConfig 를 빌드 하기 위해서는 이 모듈을 빌드 해야 한다.

https://www.gnu.org/software/gperf/

./configure

make

 

src 에 생성된 gperf /usr/bin 디렉토리에 복사 한다.

 


FontConfig 빌드

1. 소스 코드 다운로드 : https://www.freedesktop.org/software/fontconfig/release/

2. stable version : 2.13.1 version

# ./configure

# make install 실행


libjpeg 빌드

 

# petalinux-build -c jpeg

하여 아래 패키지를 복사하여 미모젯에 설치를 해준다.

rpm -ivh libjpeg62-2.0.0-r0.cortexa9t2hf_neon.rpm

rpm -ivh libturbojpeg0-2.0.0-r0.cortexa9t2hf_neon.rpm

 

DCT Encoder 가 없다고 메시지가 뜰 수 있지만 동작에는 지장이 없었습니다.

 


boost 빌드

 

# petalinux-build -c boost

 

 아래 빌드된 파일(rpm)을 Target Device 에 설치 한다.

cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/boost /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/

 

 


cairo package 설치 하기 
# petalinux-build -c cairo

cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/cairo/usr/lib/ /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/cairo/lib
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/cairo/usr/include/ /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/cairo/include


gobject-introspection-1.0 (해결)
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/gobject-introspection /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/

bin/include/lib 3 디렉토리를 넣음. 

-- Checking for module 'gobject-introspection-1.0'
--   No package 'gobject-introspection-1.0' found
-> 아래와 같이 메시지가 변경됨. 
-- Checking for module 'gobject-introspection-1.0'
--   Found gobject-introspection-1.0, version 1.58.0


gtk+ (해결)
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/gtk+ /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/gtk+3 /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/pango /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/gdk-pixbuf /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/fribidi /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/harfbuzz /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/libxcursor /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/atk /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/at-spi2-atk /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/at-spi2-core /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/gtk-doc /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs

include/bin/lib 각각 디렉토리 내용을 장치에 복사 한다.

아래와 같이 메시지가 변경 됨
 Checking for modules 'gtk+-3.0>=3.22;gdk-pixbuf-2.0>=2.36'
--   Found gtk+-3.0, version 3.22.30
--   Found gdk-pixbuf-2.0, version 2.36.11


crul

 

# petalinux-build -c curl
cp -r ./build/tmp/sysroots-components/cortexa9t2hf-neon/curl /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs


poppler-data

홈페이지의 최신 버전을 다운로드 해서  : poppler-data-0.4.11
압축을 해제 하고 make install 을 하면 usr/local/share 에 설치가 된다. 


기타 include 파일을 복사 함.

cp ./build/tmp/sysroots-components/cortexa9t2hf-neon/nspr/usr/include/nspr.h /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/include
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/nspr /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/nss/usr/include/nss3  /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs

openjpeg.h 가 없어서 
petalinux-build -c openjpeg 실행 하여 헤더 파일 복사 함. 

cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/openjpeg/usr/include/openjpeg-2.3 /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs

Couldn't find include 'GObject-2.0.gir' 

cp -rf ./build/tmp/sysroots-components/x86_64/gobject-introspection-native/usr/share/gir-1.0/ /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/gobject-introspection/usr/share/gobject-introspection-1.0 /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/share
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/gobject-introspection/usr/bin/g-ir-scanner-lddwrapper /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/share

 


https://github.com/Distrotech/transfig

petalinux-build -c libxpm

cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/libxpm  /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs

make 로 빌드 

 cp ./fig2dev/fig2dev /usr/bin

 

 

#################################3* prelink-rtld 빌드 방법
# poppler 를 make 할 때 필요한 모듈 ( 하지만 여기서 prelink-rtld 가 필요가 없어짐... 이게 없어도 빌드는 된다)
https://github.com/mhatle/prelink
다운로드 하고 압축해제 후 아래 명령어 실행
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/elfutils /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs

에러 메시지 : cannot find -liberty
libiberty.a 파일 복사 와 include 파일 복사하여 OK 

또 에러가 발생하겠지만 무시하고 -> 여기서 아래 디렉토리에 빌드가 되어 있는지 확인한다. 이것만 있으면 더이상 빌드를 하지 않아도 된다. 
prelink-cross_prelink/src/rtld/prelink-rtld:
 


cp ./build/tmp/sysroots-components/cortexa9t2hf-neon/binutils/usr/lib/libiberty.a /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/libiberty
cp -rf ./build/tmp/sysroots-components/cortexa9t2hf-neon/binutils/usr/include/libiberty /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/pkgs/libiberty

위 파일들 복사 후 아래 명령 수행


* 부록...

Cross Compile 을 위해서 xilinx.cmake 파일을 생성

 

아래 내용을 추가 하였습니다.

 

# xilinx zynq toolchain configuration


set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)


# Cross Compile 경로
set(COMPILER_ROOT /opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr/bin/arm-xilinx-linux-gnueabi/)


# Cross Compile 이름
set(CMAKE_C_COMPILER ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-g++)
set(CMAKE_LINKER ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-ld)
set(CMAKE_C_LINKER ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-ld)
set(CMAKE_CXX_LINKER ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-ld)
set(CMAKE_NM ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-nm)
set(CMAKE_OBJCOPY ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-objcopy)
set(CMAKE_OBJDUMP ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-objdump)
set(CMAKE_OBJRANLIB ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-ranlib)
set(CMAKE_C_AR ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-ar)
set(CMAKE_C_AS ${COMPILER_ROOT}arm-xilinx-linux-gnueabi-as)


# 관련 설치 복사 할 위치
set(CMAKE_INSTALL_PREFIX /mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/release/usr)


#set(CMAKE_FIND_ROOT_PATH /opt/zynq_qt/sysroots/x86_64-petalinux-linux /opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr)

빌드 명령
cmake .. -DENABLE_QT6=OFF -DENABLE_QT5=OFF -DCMAKE_TOOLCHAIN_FILE=xilinx.cmake -DCMAKE_INSTALL_PREFIX=/mnt/idehdd1/IDEDATA/Work/SubWork/PDFLib/release/usr

 

 

 

 

 

1차 에러 메시지

라이브러리를 찾지 못하는 에러

cmake .. -DENABLE_QT6=OFF -DENABLE_QT5=OFF -DCMAKE_TOOLCHAIN_FILE=xilinx.cmake --debug-trycompile –debug-output

 

 

/opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr/libexec/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/8.2.0/real-ld: cannot find Scrt1.o: No such file or directory

/opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr/libexec/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/8.2.0/real-ld: cannot find crti.o: No such file or directory

/opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr/libexec/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/8.2.0/real-ld: cannot find crtbeginS.o: No such file or directory

/opt/zynq_qt/sysroots/x86_64-petalinux-linux/usr/libexec/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/8.2.0/real-ld: cannot find -lgcc

/opt/zynq_qt/sysroots/x86_64-petalinux

 

이 원인을 찾기 위해서 위 실행 명령에 –trace 를 붙여서 디버깅을 시작

 

gcc 버전과 관련된 binutil 관련 문제라고 되어 있기 때문에 이를 무시 하기 위해서

cmake .. 으로 이 단계를 넘어가버림.

 

이후

cmake .. -DCMAKE_TOOLCHAIN_FILE=xilinx.cmake --debug-trycompile --debug-output

이 명령을 수행하면 다음 단계로 넘어간다.

 

(현재 설치된 Ubuntu 의 Dependency 가 꼬여버려서 새로 설치하기가 싫어서 여기서 멈춤 ㅠ.ㅠ)

반응형

댓글