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
에러메시지의
에러메시지의 내용으로 봐선 링커가 directfb 라이브러리 링크를 시도하지도 않고 있습니다.
directfb.pc 가 있는 곳을 PKG_CONFIG_PATH 로 잡아주세요.
귀찮으시면
directfb.pc 의 내용을 보시고 CFLAGS LDFLAGS 를 알아내셔도 됩니다.
fc5 에서 directfb, directfb-devel 을 설치하면
처럼 나옵니다.
directfb.pc 는 directfb-devel 패키지에 들어있는 파일입니다.
올려주신 코드를 컴파일해서 실행했더니
라고 나오네요. 까만 화면만 5초 정도 화면에 보였습니다.
vesafb 사용하고 있고, 1024x768 32bpp 로 되어 있습니다.
~/.directfbrc
~/.directfbrc 파일을
처럼 만들고, 적어주신 소스 중
를 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
정확하게 어떻게
정확하게 어떻게 설치를 하실려고 하신건지 잘 모르겠습니다.
앞에서 답변을 달아주신분께서는 fedora의 패키지 중 directfb, directfb-devel 패키지를 설치하라고 하신거였습니다.
directfb-devel 패키지에 원하시는 헤더와 pkg-config 설정이 다 들어있습니다.
위 질문에 대한 답변은, pkg-config의 출력값을 명령행에다 추가하는 의도라면, '(single quote)가 아니라 `(back quote)로 묶어서 사용하셔야 합니다.
----
:LOL:
http://luna.onionmixer.net
http://lunapapa.egloos.com
댓글 달기