[DirectFB] #include <directfb.h>를 못 읽나봅니다

이석원의 이미지

아래 코드를 실행시키면 directfb.h를 찾을 수 없다고 나옵니다. directfb를 세팅했는데도 말입니다.

directfb.h가 위치한 곳은 /usr/local/include/directfb입니다

뭘 어떻게 설정해야 하는지 모르겠습니다.

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/home/ooo/directfb는 했습니다.

========================================== test.c ========================================================
#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;
}

================================================== 돌려보면요~~~ ================================================

[e_s_w@Death test]$ gcc -o test test.c
test.c:4:22: error: directfb.h: No such file or directory
test.c:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
test.c:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
test.c: In function 'main':
test.c:26: error: 'DFBSurfaceDescription' undeclared (first use in this function)
test.c:26: error: (Each undeclared identifier is reported only once
test.c:26: error: for each function it appears in.)
test.c:26: error: expected ';' before 'dsc'
test.c:28: error: 'DFBResult' undeclared (first use in this function)
test.c:28: error: expected ';' before 'err'
test.c:28: error: 'err' undeclared (first use in this function)
test.c:28: error: 'DFB_OK' undeclared (first use in this function)
test.c:30: error: expected ';' before 'err'
test.c:32: error: 'dsc' undeclared (first use in this function)
test.c:32: error: 'DSDESC_CAPS' undeclared (first use in this function)
test.c:33: error: 'DSCAPS_PRIMARY' undeclared (first use in this function)
test.c:33: error: 'DSCAPS_FLIPPING' undeclared (first use in this function)
test.c:35: error: expected ';' before 'err'
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:41: error: expected ';' before 'err'
test.c:43: error: 'primary' undeclared (first use in this function)
test.c:44: error: 'dfb' undeclared (first use in this function)

bushi의 이미지

아직 성공 못하셨군요.

PKG_CONFIG_PATH 는 pkg-config 라는 명령이 참조하는 환경변수 입니다.
pkg-config 는 패키지를 설치할 때 같이 설치된 어쩌구.pc 를 읽어서 해당 패키지를 사용할 때 컴파일 옵션, 링크 옵션을 어떻게 줘야 하는 지 편하게 알아내도록 도와줍니다.

예를 들어,
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/home/ooo/directfb
로 하고
pkg-config --cflags directfb
라는 명령을 주면,
pkg-config 는 /usr/local/lib/pkgconfig/directfb.pc 를 먼저 찾아보고
없으면 /home/ooo/directfb/directfb.pc 를 찾습니다.
directfb.pc 가 있으면 그 파일을 열어서 컴파일 할 때 참조해야 할 CFLAGS 정보를 분석한 다음 사용자에게 보여줍니다.

그러니, /usr/local/lib/pkgconfig/directfb.pc 혹은 /home/ooo/directfb/directfb.pc 가 있다면,
gcc `pkg-config --cflags directfb` `pkg-config --libs directfb` -o test test.c
처럼 사용하시면 됩니다.
' 가 아니라 ` 입니다.

그래도 안되시면
echo $PKG_CONFIG_PATH
pkgconfig --cflags directfb
pkgconfig --libs directfb
의 실행결과를 여기다 올려주세요.

bushi의 이미지

이전 글에 directfb-config 를 말씀드렸습니다.
이것도 directfb 를 설치하시면 어딘가에 같이 설치됩니다.
directfb-config 라는 실행파일이 어디있는지 찾아보시고,
pkg-config 대신 directfb-config 를 사용하셔도 됩니다.
둘의 차이점은... pkg-config 는 범용 툴이고,
directfb-config 는 directfb 에서 제공하는 전용 툴이라는 겁니다.
때문에 directfb-config 는 PKG_CONFIG_PATH 따위의 환경변수를 참조하지 않습니다.

bushi의 이미지

pkg-config 고 directfb-config 불문하고, directfb 라는 패키지를 반드시 "설치"까지 진행하셔야만 정상동작합니다.
tar.gz 를 풀어서 직접 make 를 때리셨다면,
make install 까지 하셔야만 합니다.

이석원의 이미지

안녕하세요~ 답변을 참고하여 다시 해 봤습니다.
'가 아닌 `이거로 했더니 실행파일이 생성되었습니다.
아싸~~ 소리를 한번 지르고 실행시켜봤죠
그랬더니..

[root@Death test]# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/home/e_s_w/directfb/
[root@Death test]# pkg-config --cflags directfb-D_REENTRANT -I/usr/local/include/directfb
[root@Death test]# gcc `pkg-config --cflags directfb` `pkg-config --libs directfb` -o test test.c
[root@Death test]# ll
합계 12
-rwxr-xr-x 1 root root 6762 1월 15 09:17 test
-rw-rw-r-- 1 e_s_w e_s_w 1632 1월 10 13:01 test.c
[root@Death test]# ./test
./test: error while loading shared libraries: libdirectfb-1.0.so.0: cannot open shared object file: No such file or directory
[root@Death test]#

이렇게 나왔습니다.

libdirectfb-1.0.so.0 파일이 뭔가 싶어서 찾아가 봤습니다.

/usr/local/lib에

lrwxrwxrwx 1 root root 22 Jan 9 17:00 libdirect-1.0.so.0 -> libdirect-1.0.so.0.0.0
-rwxr-xr-x 1 root root 82406 Jan 9 17:00 libdirect-1.0.so.0.0.0

이렇게 되어 있었습니다..

뭔가 싶어서 실행시켜 봤더니....이렇게 나왔습니다..

[e_s_w@Death lib]$ ./libdirectfb-1.0.so.0.0.0
Segmentation fault

[e_s_w@Death lib]$ ./libdirectfb-1.0.so.0
Segmentation fault

[e_s_w@Death lib]$

이제 어쩌죠....뭐가 잘 못 되서 실행이 안되는 것일까요...

매번 감사드립니다...

익명 사용자의 이미지

export LD_LIBRARY_PATH=/usr/local/lib

댓글 달기

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 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.