directfb를 이용하여 선을 그리기 예제를 실행했는데 이러한 에러가 나왔습니다. directfb 세팅부터 하나도 모르겠군요....

이석원의 이미지

소스코드는 아래와 같습니다
====================================
#include
#include

#include

static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;

static int screen_width = 0;
static int screen_height = 0;


#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}


int main(int argc, char **argv)
{
DFBSurfaceDescription dsc;

DFBCHECK(DirectFBInit (&argc, &argv));

DFBCHECK(DirectFBCreate (&dfb));

DFBCHECK(dfb->SetCooperativeLevel (dfb,DFSCL_FULLSCREEN));

dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;

DFBCHECK(dfb->CreateSurface(dfb,&dsc,&primary));
DFBCHECK(primary->GetSize(primary,&screen_width, &screen_height));
DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height));
DFBCHECK (primary->SetColor (primary, 0xff, 0x00, 0x00, 0xff));
DFBCHECK (primary->DrawLine (primary,0,0, screen_width,screen_height ));

DFBCHECK (primary->Flip (primary, NULL, 0));
sleep (5);
primary->Release( primary );
dfb->Release( dfb );

return 23;
}

===================================

발생한 에러는 아래와 같습니다

========================================================================================================
root@DeathMania test]# gcc `pkg-config --cflags directfb` -o test b.c `pkg-config --libs directfb` -g
Package directfb was not found in the pkg-config search path.
Perhaps you should add the directory containing `directfb.pc'
to the PKG_CONFIG_PATH environment variable
No package 'directfb' found
Package directfb was not found in the pkg-config search path.
Perhaps you should add the directory containing `directfb.pc'
to the PKG_CONFIG_PATH environment variable
No package 'directfb' found
/tmp/cccE8C4c.o: In function `main':/home/DeathMania/test/b.c:29: undefined reference to `DirectFBInit'
:/home/DeathMania/test/b.c:29: undefined reference to `DirectFBErrorFatal'
:/home/DeathMania/test/b.c:31: undefined reference to `DirectFBCreate'
:/home/DeathMania/test/b.c:31: undefined reference to `DirectFBErrorFatal'
:/home/DeathMania/test/b.c:33: undefined reference to `DirectFBErrorFatal'
:/home/DeathMania/test/b.c:38: undefined reference to `DirectFBErrorFatal'
:/home/DeathMania/test/b.c:39: undefined reference to `DirectFBErrorFatal'
:/home/DeathMania/test/b.c:40: undefined reference to `DirectFBErrorFatal'
/tmp/cccE8C4c.o:/home/DeathMania/test/b.c:41: more undefined references to `DirectFBErrorFatal' follow
collect2: ld returned 1 exit status

bushi의 이미지

에러메시지의 내용으로 봐선 링커가 directfb 라이브러리 링크를 시도하지도 않고 있습니다.
directfb.pc 가 있는 곳을 PKG_CONFIG_PATH 로 잡아주세요.
귀찮으시면
directfb.pc 의 내용을 보시고 CFLAGS LDFLAGS 를 알아내셔도 됩니다.

fc5 에서 directfb, directfb-devel 을 설치하면

[bushi@rose net]$ pkg-config --cflags directfb
-D_REENTRANT -D_GNU_SOURCE -I/usr/include/directfb
[bushi@rose net]$ pkg-config --libs directfb
-ldirectfb -lz -lfusion -ldirect -lpthread -ldl
[bushi@rose net]$

처럼 나옵니다.
directfb.pc 는 directfb-devel 패키지에 들어있는 파일입니다.

올려주신 코드를 컴파일해서 실행했더니

       ---------------------- DirectFB v0.9.24 ---------------------
             (c) 2000-2002  convergence integrated media GmbH
             (c) 2002-2004  convergence GmbH
        -----------------------------------------------------------
 
(*) DirectFB/Core: Single Application Core. (2006-03-05 13:57)
(*) Direct/Memcpy: Using MMXEXT optimized memcpy()
(*) Direct/Thread: Running 'VT Switcher' (CRITICAL, 25945)...
(*) Direct/Thread: Running 'Keyboard Input' (INPUT, 25946)...
 (!!!)  *** UNIMPLEMENTED [fusion_reactor_set_lock] *** [reactor.c:797]
(*) DirectFB/Input: Keyboard 0.9 (convergence integrated media GmbH)
(*) Direct/Thread: Running 'PS/2 Input' (INPUT, 25947)...
(*) DirectFB/Input: IMPS/2 Mouse 1.0 (Convergence GmbH)
(*) Direct/Thread: Running 'Linux Input' (INPUT, 25948)...
(*) DirectFB/Input: AT Translated Set 2 keyboard (1) 0.1 (convergence integrated media GmbH)
(*) Direct/Thread: Running 'Linux Input' (INPUT, 25949)...
(*) DirectFB/Input: PS2++ Logitech Wheel Mouse (2) 0.1 (convergence integrated media GmbH)
(*) Direct/Thread: Running 'Linux Input' (INPUT, 25950)...
(*) DirectFB/Input: PC Speaker (3) 0.1 (convergence integrated media GmbH)
(*) DirectFB/Genefx: MMX detected and enabled
(*) DirectFB/Graphics: MMX Software Rasterizer 0.6 (convergence integrated media GmbH)
(*) DirectFB/Core/WM: Default 0.2 (Convergence GmbH)
 (!!!)  *** WARNING [fbdev driver possibly buggy] *** [fbdev.c:1736 in dfb_fbdev_set_mode()]
 (!!!)  *** ONCE [unsupported destination format] *** [generic.c:6314 in gAcquire()]

라고 나오네요. 까만 화면만 5초 정도 화면에 보였습니다.
vesafb 사용하고 있고, 1024x768 32bpp 로 되어 있습니다.
bushi의 이미지

~/.directfbrc 파일을

system=fbdev
fbdev=/dev/fb0
mode=1024x768
depth=32
memcpy=help
force-windowed
vt-switch
graphics-vt
no-cursor

처럼 만들고, 적어주신 소스 중
DFBCHECK(dfb->SetCooperativeLevel (dfb,DFSCL_FULLSCREEN));

를 comment out 하니 까만바탕에 빨간 줄이 역슬래시 대각선으로 나타납니다.

그리고, pkg-config 보다는 패키지에 포함된 directfb-config 를 사용하는 게 더 좋을 것 같습니다.

이석원의 이미지

fedora를 다시 설치해서 해봤습니다.

freetype, libjpeg, zlib, libpng, directfb를 설치했습니다.

그리고 어제 예제 파일을 그대로 가지고 왔습니다.

답변해 주신대로 PKG_CONFIG_PATH를 directfb.pc파일이 있는 =/home/e_s_w/directfb 로 했더니 아래와 같이 나왔습니다.

[e_s_w@Death test]$ pkg-config --cflags directfb

-D_REENTRANT -I/usr/local/include/directfb

[e_s_w@Death test]$ pkg-config --libs directfb

-L/usr/local/lib -ldirectfb -lz -lfusion -ldirect -lpthread -ldl

[e_s_w@Death test]$ gcc -o test test.c
test.c:4:22: error: directfb.h: No such file or directory
test.c:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
test.c:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
test.c: In function 'main':
test.c:27: error: 'DFBSurfaceDescription' undeclared (first use in this function)
test.c:27: error: (Each undeclared identifier is reported only once
test.c:27: error: for each function it appears in.)
test.c:27: error: expected ';' before 'dsc'
test.c:29: error: 'DFBResult' undeclared (first use in this function)
test.c:29: error: expected ';' before 'err'
test.c:29: error: 'err' undeclared (first use in this function)
test.c:29: error: 'DFB_OK' undeclared (first use in this function)
test.c:31: error: expected ';' before 'err'
test.c:33: error: 'dsc' undeclared (first use in this function)
test.c:33: error: 'DSDESC_CAPS' undeclared (first use in this function)
test.c:34: error: 'DSCAPS_PRIMARY' undeclared (first use in this function)
test.c:34: error: 'DSCAPS_FLIPPING' undeclared (first use in this function)
test.c:36: error: expected ';' before 'err'
test.c:37: error: expected ';' before 'err'
test.c:38: error: expected ';' before 'err'
test.c:39: error: expected ';' before 'err'
test.c:40: error: expected ';' before 'err'
test.c:42: error: expected ';' before 'err'
test.c:44: error: 'primary' undeclared (first use in this function)
test.c:45: error: 'dfb' undeclared (first use in this function)
[e_s_w@Death test]$

이렇게 에러가 납니다...directfb.h 파일을 못 찾아서 생겨난 문제 같은데요..
어떻게 해야 합니까.?

아,DFBCHECK(dfb->SetCooperativeLevel (dfb,DFSCL_FULLSCREEN));는 빼고 했습니다.
그리고
[e_s_w@Death test]$ gcc 'pkg-config --cflags directfb' -o test test.c 'pkg-config --libs directfb'
이렇게 하면
gcc: pkg-config --cflags directfb: No such file or directory
gcc: pkg-config --libs directfb: No such file or directory
와 같은 에러가 발생했습니다.
test.c:4:22: error: directfb.h: No such file or directory

dalgarak의 이미지

정확하게 어떻게 설치를 하실려고 하신건지 잘 모르겠습니다.

앞에서 답변을 달아주신분께서는 fedora의 패키지 중 directfb, directfb-devel 패키지를 설치하라고 하신거였습니다.
directfb-devel 패키지에 원하시는 헤더와 pkg-config 설정이 다 들어있습니다.

[e_s_w@Death test]$ gcc 'pkg-config --cflags directfb' -o test test.c 'pkg-config --libs directfb'
이렇게 하면

위 질문에 대한 답변은, pkg-config의 출력값을 명령행에다 추가하는 의도라면, '(single quote)가 아니라 `(back quote)로 묶어서 사용하셔야 합니다.

----
:LOL:

http://luna.onionmixer.net
http://lunapapa.egloos.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.