본문 바로가기
IT/SW

DirectFB + GTK+ (cross compile)

by 낭만테라스 2018. 7. 11.

DirectFB + GTK+ (cross compile)

DirectFB + GTK+

설치 방법 참조
http://www.directfb.org/wiki/index.php/Projects:GTK_on_DirectFB_for_Embedded_Systems

1. 폴더 생성
/opt/gtkdfb/usr/local에 install 예정

2. 환경 변수 설정

(fedora쪽에서 설정하기)
/opt/eldk/ppc_4xxFP/opt/gtkdfb/usr/local
$ export PREFIX=/opt/eldk/ppc_4xxFP/opt/gtkdfb/usr/local
$ export LD_LIBRARY_PATH=$PREFIX/lib
$ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig
$ export HOST=powerpc-linux
$ export BUILD=powerpc-linux
$ export TARGET=powerpc-linux
$ export COMPILER=ppc_4xxFP-gcc
$ export AR=ppc_4xxFP-ar
$ export AS=ppc_4xxFP-as
$ export CC=ppc_4xxFP-gcc
$ export CXX=ppc_4xxFP-c++
$ export GXX=ppc_4xxFP-g++
$ export LD=ppc_4xxFP-ld
$ export NM=ppc_4xxFP-nm
$ export RANLIB=ppc_4xxFP-ranlib
$ export STRIP=ppc_4xxFP-strip

3. install

DirectFB-1.4.3
$ tar zxvf DirectFB-1.4.3.tar.gz
$ cd DirectFB-1.4.3
$ vi configure
cross_compiling=yes
$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX
vi lib/direct/ppcasm_memcpy_cachable.S (DirectFB버그인갑다.)
(37L) #include "../../config.h"
$ gmake
$ gmake install


glib-2.12.13 -> pango깔 때 버전 문제 생겨서 glib-2.16으로 교체

$ tar zxvf glib-2.12.13.tar.gz -> tar zxvf glib-2.16.tar.gz
$ cd glib-2.12.13 -> glib-2.16

$vi configure
cross_compiling=yes
cross compile error를 막기위해
"cannot run test program while cross compiling" 찾고, "cross-compiling" 도 찾고 
{ (exit 1); exit 1; }; <=========== 그 뒤 바로 나오는 이 글을 삭제.
그러면
checking for growing stack pointer... configure: error: cannot run test program while \
cross compiling
See config.log for more details.
이런 메시지가 뜨지만 무시하고 make하면 된다.

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX
$ gmake
$ gmake install




atk-1.19.3 


$ vi configure
cross_compiling=yes
$ ./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --disable-glibtest

/, /atk,/tests에 있는 세 군데의 Makefile에서 DEP_CFLAGS, DEP_LIBS, GLIB_CFLAGS, GLIB_LIBS부분을 //가 두개로 된 걸 제거해서 아래와 같이 된지 확인(단 내경로로해야한다. 길어서, 내 경로 표기는 생략.)
vi Makefile
vi atk/Makefile
DEP_CFLAGS = -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include
DEP_LIBS = -L/opt/gtkdfb/usr/local/lib \
-lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
GLIB_CFLAGS = -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include
GLIB_LIBS = -L/opt/gtkdfb/usr/local/lib -lgobject-2.0 \
-lgmodule-2.0 -ldl -lglib-2.0

$ gmake
$ gmake install



Freetype2

$ export BUILD=i386-linux (configure에 cross_compiling 설정 부분이 없음)
$./configure --host=$HOST --build=$BUILD --prefix=$PREFIX
$ gmake
$ gmake install
$ export BUILD=powerpc-linux


libxml2-2.6.29 

$ vi configure
cross_compiling=yes
$./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --without-debug
$ gmake
$ gmake install



Fontconfig
freetype2/freetype/config -> freetype2삭제하고 freetype/config로 폴더 변경해야지 freetype의 헤더파일 참조시 error가 발생안한다.

$ vi configure
cross_compiling=yes
$./configure --build=$BUILD --host=$HOST \
--prefix=$PREFIX \
--with-freetype-config=$PREFIX/bin/freetype-config --enable-libxml2 --with-arch=powerpc
$ gmake
$ gmake install


zlib

$./configure --prefix=$PREFIX --shared
$ gmake
$ gmake install



libpng

$ vi configure
cross_compiling=yes
:%s/ac_cv_lib_z_zlibVersion=no/ac_cv_lib_z_zlibVersion=yes/g
$./configure --host=$HOST --build=$BUILD --prefix=$PREFIX
$ gmake
$ gmake install


Cairo
$ vi configure
cross_compiling=yes
:%s/ac_cv_lib_z_compress=no/ac_cv_lib_z_compress=yes/g
:%s/ac_header_compiler=no/ac_header_compiler=yes/g
:%s/ac_header_preproc=no/ac_header_preproc=yes/g

$ directfb_CFLAGS="-I$PREFIX/include/directfb" \
directfb_LIBS="$PREFIX/lib/libdirectfb.so \
$PREFIX/lib/libdirect.so \
$PREFIX/lib/libfusion.so" \
png_REQUIRES="$PREFIX/lib/pkgconfig" \
png_CFLAGS="-I$PREFIX/include" \
png_LIBS=$PREFIX/lib/libpng12.so \
FONTCONFIG_CFLAGS="-I$PREFIX/include/fontconfig" \
FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so \
FREETYPE_CFLgmakeAGS="-I$PREFIX/include/freetype2" \
FREETYPE_LIBS=$PREFIX/lib/libfreetype.so \
./configure --prefix=$PREFIX --build=$BUILD --host=$HOST \
--enable-directfb=yes --without-x --disable-xlib --disable-xlib-xrender \
--disable-win32 --disable-pdf --disable-ps --disable-svg --enable-png
$ gmake
$ gmake install



pango-1.16.4 

$ vi configure
cross_compiling=true
have_cairo=true
have_cairo_png=true
have_cairo_freetype=true

$ GLIB_CFLAGS="-I$PREFIX/include/glib-2.0 \
-I$PREFIX/lib/glib-2.0/include" \
GLIB_LIBS="$PREFIX/lib/libglib-2.0.so \
$PREFIX/lib/libgmodule-2.0.so \
$PREFIX/lib/libgobject-2.0.so \
$PREFIX/lib/libfontconfig.so \
$PREFIX/lib/libxml2.so \
$PREFIX/lib/libfreetype.so" \
CAIRO_CFLAGS="-I$PREFIX/include/cairo" \
CAIRO_LIBS=$PREFIX/lib/libcairo.so \
FONTCONFIG_CFLAGS="-I$PREFIX/include/fontconfig" \
FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so \
FREETYPE_CFLAGS="-I$PREFIX/include/freetype2" \
FREETYPE_LIBS=$PREFIX/lib/libfreetype.so \
FREETYPE_CONFIG=$PREFIX/bin/freetype-config \
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --without-x
(Makefile에서 GLIB_CFLAGS가 바로 잡힌지 check)
$vi examples/Makefile GLIB_LIBS변수에다 붙이기
/opt/gtkdfb/usr/local/lib/libpng12.so \
/opt/gtkdfb/usr/local/lib/libdirectfb.so \
/opt/gtkdfb/usr/local/lib/libdirect.so \
/opt/gtkdfb/usr/local/lib/libfusion.so
$vi tools/Makefile 과 tests/Makefile 각각을 추가
LIBS = $(GLIB_LIBS) 
(GLIB_CFLAGS, GLIB_LIBS의 path들이 정상적인가 check)
$ gmake
$ gmake install


GTK+

설정없애기 : export LD_LIBRARY_PATH= 

$ vi configure
cross_compiling = yes
"Can't find cairo-pdf.h"랑 
"Can't find cairo-pdf.h"을 검색해서 
{ (exit 1); exit 1; }; <=========== 그 뒤 바로 나오는 이 글을 삭제하고 jump. (glib처럼cross-compile error로 보인다)

cairo에서 pdf/ps를 빼고 싶어도 옵션이 없기 때문에
vi gtk/gtkprintoperation.c
vi gtk/gtkprintoperation-unix.c
vi modules/printbackends/lpr/gtkprintbackendlpr.c
vi modules/printbackends/file/gtkprintbackendfile.c 파일들에서 모두 아래를 찾아서 막기.

#include 
#include 

cairo_pdf_surface_set_size()
cairo_pdf_surface_create()
cairo_ps_surface_create_for_stream()

$ PKG_CONFIG=$PREFIX/bin/pkg-config \
BASE_DEPENDENCIES_CFLAGS="-I$PREFIX/include -I$PREFIX/lib/glib-2.0/include -I$PREFIX/include/glib-2.0 \
-I$PREFIX/include/pango-1.0 -I$PREFIX/include/cairo -I$PREFIX/include/atk-1.0" \
BASE_DEPENDENCIES_LIBS="-L$PREFIX/lib $PREFIX/lib/libglib-2.0.so $PREFIX/lib/libgobject-2.0.so \
$PREFIX/lib/libgmodule-2.0.so $PREFIX/lib/libfontconfig.so $PREFIX/lib/libxml2.so" \
GLIB_CFLAGS="-I$PREFIX/include -I$PREFIX/lib/glib-2.0/include -I$PREFIX/include/glib-2.0" \
GLIB_LIBS="-L$PREFIX/lib $PREFIX/lib/libglib-2.0.so $PREFIX/lib/libgobject-2.0.so \
$PREFIX/lib/libgmodule-2.0.so $PREFIX/lib/libfontconfig.so $PREFIX/lib/libxml2.so" \
PANGO_CFLAGS="-I$PREFIX/include/pango-1.0" \
PANGO_LIBS="-L$PREFIX/lib $PREFIX/lib/libpango-1.0.so $PREFIX/lib/libpangoft2-1.0.so \
$PREFIX/lib/libpangocairo-1.0.so" \
GDK_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include \
-I$PREFIX/include/pango-1.0 -I$PREFIX/include/cairo -I$PREFIX/include -D_REENTRANT -D_GNU_SOURCE \
-I$PREFIX/include -I$PREFIX/include/directfb" \
GDK_DEP_LIBS="-L$PREFIX/lib -ldirectfb -lfusion -ldirect -lpthread -ldl -lpangocairo-1.0 \
-lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lm" \
GDK_PIXBUF_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include \
-I$PREFIX/include -I$PREFIX/../include" \
GDK_PIXBUF_DEP_LIBS="-L$PREFIX/lib -lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0 -lpng12 -lm" \
GTK_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 -I$PREFIX/lib/glib-2.0/include \
-I$PREFIX/include/pango-1.0 -I$PREFIX/include/cairo -I$PREFIX/include -D_REENTRANT -D_GNU_SOURCE \
-I$PREFIX/../include/directfb -I$PREFIX/include/atk-1.0 -I$PREFIX/../include" \
GTK_DEP_LIBS="-L$PREFIX/lib -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 \
-ldl -lglib-2.0 -lcairo -lpng12 -lm" \
GDK_EXTRA_CFLAGS="-I$PREFIX/include" \
GDK_EXTRA_LIBS="-L$PREFIX/lib -ldirectfb -lz -lfusion -ldirect -lpthread -ldl" \
./configure \
--host=$HOST \
--build=$BUILD \
--prefix=$PREFIX \
--with-gdktarget=directfb \
--without-libtiff \
--disable-glibtest \
--disable-largefile \
--disable-modules \
--without-libjpeg \
--with-included-loaders=gif,png,xpm
(필요시 jpeg를 위해서 --without-libjpeg제거하고 필요한 부분 -ljpeg 추가하여 하장)


모든 Makefile을 수정
BASE_DEPENDENCIES_CFLAGS = -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include \
-I/opt/gtkdfb/usr/local/include/pango-1.0 \
-I/opt/gtkdfb/usr/local/include/cairo \
-I/opt/gtkdfb/usr/local/include/atk-1.0
BASE_DEPENDENCIES_LIBS = -L/opt/gtkdfb/usr/local/lib \
-latk-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lcairo
GDK_DEP_CFLAGS = -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include \
-I/opt/gtkdfb/usr/local/include/pango-1.0 \
-I/opt/gtkdfb/usr/local/include/cairo \
-I/opt/gtkdfb/usr/local/include \
-I/opt/gtkdfb/usr/local/freetype2 \
-I/opt/gtkdfb/usr/local/libpng12 -D_REENTRANT -D_GNU_SOURCE \
-I/opt/gtkdfb/usr/include/directfb
GDK_DEP_LIBS = -L/opt/gtkdfb/usr/local/lib \
-L/opt/gtkdfb/usr/lib -ldirectfb -lfusion -ldirect -lpthread \
-ldl -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lm
GDK_PIXBUF_DEP_CFLAGS = -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include \
-I/opt/gtkdfb/usr/local/include
GDK_PIXBUF_DEP_LIBS = -L/opt/gtkdfb/usr/local/lib \
-L/opt/gtkdfb/usr/local/lib 
-lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0 -lpng12 -ljpeg -lm
GLIB_CFLAGS = -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include
GLIB_LIBS = -pthread -L/opt/gtkdfb/usr/local/lib \
-lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0
GTK_DEP_CFLAGS = -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 \
-I/opt/gtkdfb/usr/local/lib/glib-2.0/include \
-I/opt/gtkdfb/usr/local/include/pango-1.0 \
-I/opt/gtkdfb/usr/local/include/cairo \
-I/opt/gtkdfb/usr/local/include/atk-1.0 \
-I/opt/gtkdfb/usr/local/include -D_REENTRANT -D_GNU_SOURCE \
-I/opt/gtkdfb/usr/include/directfb
GTK_DEP_LIBS = -L/opt/gtkdfb/usr/local/lib \
/opt/gtkdfb/usr/lib/libdirectfb.so -lpangocairo-1.0 -lpango-1.0 \
-latk-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lcairo -lpng12 -lfontconfig -lxml2 -lm

$ vi gdk/directfb/Makefile 에서 INCLUDE변수 마지막 라인에 넣기.
$(GDK_DEP_CFLAGS)

$vi gdk/Makefile 에서 GDK_DEP_LIBS변수에 지정하기.
GDK_DEP_LIBS = -L/opt/gtkdfb/usr/local/lib \
-lpthread -ldl -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 \
-lgmodule-2.0 -lglib-2.0 -lpng12 -lm

$ vi gtk/Makefile
#$(LINK) $(gtk_query_immodules_2_0_LDFLAGS) $(gtk_query_immodules_2_0_OBJECTS) \
$(gtk_query_immodules_2_0_LDADD) $(LIBS)

$vi demos/gtk-demo/Makefile GDK_DEP_LIBS를 설정.
GDK_DEP_LIBS = -L/opt/gtkdfb/usr/local/lib -lpthread -ldl \
-lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 \
-lpng12 -lm /opt/gtkdfb/usr/lib/libdirectfb.so \
/opt/gtkdfb/usr/lib/libdirect.so /opt/gtkdfb/usr/lib/libfusion.so

vi demos/gtk-demo/Makefile
vi demos/Makefile
vi tests/Makefile 
vi perf/Makefile 4개 모두에서 LIBS를 각각 설정

LIBS = /opt/gtkdfb/usr/lib/libdirectfb.so \
/opt/gtkdfb/usr/lib/libdirect.so /opt/gtkdfb/usr/lib/libfusion.so

============================
(펌)
cairo : 2D 그래픽 라이브러리 벡터폰트 pango : 다양한 기능의 폰트 렌더러
(사전에 build가 되어야 하는 것 glib, pixmap, fontconfig, freetype2, libpng, libxml2등)

cairo-pango로 할 수 있는 것

cairo를 백엔드 기능으로 적용하여 pango를 빌드해서 쓰면 여러가지 작업을 할 수 있다.
예를 들어 글자를 원형으로 굴려쓰기라든가, 문자열 내에 span태그등을 넣어 데코레이션을 줄 수 있다. 또한 정해진 사각 영역안에 문단 흐르기등을 자동화 할 수 있다.



./configure --build=i386-linux --host=powerpc-linux \
--with-gfxdrivers=nvidia --disable-joystick \
--disable-jpeg --enable-fbdev \
--disable-x11 --disable-multi --prefix=$PREFIX


'IT > SW' 카테고리의 다른 글

X-window (x11) 란?  (0) 2018.07.11
Frame buffer 란  (0) 2018.07.11
DirectFB + GTK+ (target compile)  (0) 2018.07.11
DirectFB + GTK+ 설치 순서  (0) 2018.07.11
심볼릭 링크 걸기 & 해제 (DirectFB + GTK+)  (0) 2018.07.11

댓글