c - How to compile Cogl hello example -
my environment fedora 21, play around hello tutorial http://www.cogl3d.org/hello.html, shows:
building example
if save above code file named hello.c can compile example follows:
gcc -o hello hello.c
pkg-config --cflags --libs cogl2 glib-2.0
but can find cogl2 library ?
if doesn't include cogl library:
[xiaobai@xiaobai cogl]$ gcc -o hello hello.c `pkg-config --cflags --libs glib-2.0` hello.c:1:23: fatal error: cogl/cogl.h: no such file or directory #include <cogl/cogl.h> ^ compilation terminated. [xiaobai@xiaobai cogl]$
i tried dnf search cogl
there's cogl, no such thing cogl2:
[xiaobai@xiaobai cogl]$ dnf search cogl [sudo] password xiaobai: ================================================================= n/s matched: cogl ================================================================== cogl.x86_64 : library using 3d graphics hardware draw pretty pictures cogl.i686 : library using 3d graphics hardware draw pretty pictures cogl-doc.noarch : documentation cogl cogl-devel.x86_64 : cogl development environment cogl-devel.i686 : cogl development environment [xiaobai@xiaobai cogl]$
i search cogl.h, no such cogl2 too:
[xiaobai@xiaobai yum]$ dnf provides */cogl.h cogl-devel-1.18.2-9.fc21.x86_64 : cogl development environment repo : @system cogl-devel-1.18.2-9.fc21.i686 : cogl development environment repo : fedora cogl-devel-1.18.2-9.fc21.x86_64 : cogl development environment repo : fedora [xiaobai@xiaobai yum]$
i can't use pkg-config find neither cogl nor cogl2:
[xiaobai@xiaobai cogl]$ pkg-config --cflags --libs cogl2 cogl package cogl2 not found in pkg-config search path. perhaps should add directory containing `cogl2.pc' pkg_config_path environment variable no package 'cogl2' found package cogl not found in pkg-config search path. perhaps should add directory containing `cogl.pc' pkg_config_path environment variable no package 'cogl' found [xiaobai@xiaobai cogl]$
so tried cogl:
$ gcc -o hello hello.c
pkg-config --cflags --libs glib-2.0
-i/usr/include/cogl/
, shows lot of error messages:
[xiaobai@xiaobai cogl]$ gcc -o hello hello.c `pkg-config --cflags --libs glib-2.0` -i/usr/include/cogl/ hello.c:45:17: error: unknown type name ‘coglonscreen’ frame_event_cb (coglonscreen *onscreen, ^ hello.c:46:17: error: unknown type name ‘coglframeevent’ coglframeevent event, ^ hello.c:47:17: error: unknown type name ‘coglframeinfo’ coglframeinfo *info, ^ hello.c:59:11: error: unknown type name ‘coglonscreen’ dirty_cb (coglonscreen *onscreen, ^ hello.c:60:17: error: unknown type name ‘coglonscreendirtyinfo’ const coglonscreendirtyinfo *info, ^ hello.c: in function ‘main’: hello.c:86:14: warning: assignment makes pointer integer without cast data.ctx = cogl_context_new (null, &error); ^ hello.c:92:13: warning: assignment makes pointer integer without cast data.fb = cogl_onscreen_new (data.ctx, 640, 480); ^ hello.c:98:19: warning: assignment makes pointer integer without cast data.pipeline = cogl_pipeline_new (data.ctx); ^ hello.c:100:17: warning: assignment makes pointer integer without cast cogl_source = cogl_glib_source_new (data.ctx, g_priority_default); ^ hello.c:105:39: error: ‘frame_event_cb’ undeclared (first use in function) frame_event_cb, ^ hello.c:105:39: note: each undeclared identifier reported once each function appears in hello.c:110:39: error: ‘dirty_cb’ undeclared (first use in function) dirty_cb, ^ [xiaobai@xiaobai cogl]$
any appreciate.
[update] i've tried @cyb3r solution still no luck:
[xiaobai@xiaobai cogl]$ pkg-config --cflags --libs cogl-2.0-experimental glib-2.0 -pthread -i/usr/include/cogl -i/usr/include/gdk-pixbuf-2.0 -i/usr/include/libpng16 -i/usr/include/libdrm -i/usr/include/glib-2.0 -i/usr/lib64/glib-2.0/include -lcogl -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lwayland-egl -lwayland-client -lgbm -ldrm -lwayland-server -legl -lx11 -lxext -lxdamage -lxfixes -lxcomposite -lxrandr -lglib-2.0 [xiaobai@xiaobai cogl]$ gcc -pthread -i/usr/include/cogl -i/usr/include/gdk-pixbuf-2.0 -i/usr/include/libpng16 -i/usr/include/libdrm -i/usr/include/glib-2.0 -i/usr/lib64/glib-2.0/include -lcogl -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lwayland-egl -lwayland-client -lgbm -ldrm -lwayland-server -legl -lx11 -lxext -lxdamage -lxfixes -lxcomposite -lxrandr -lglib-2.0 hello.c hello.c:45:17: error: unknown type name ‘coglonscreen’ frame_event_cb (coglonscreen *onscreen, ^ hello.c:46:17: error: unknown type name ‘coglframeevent’ coglframeevent event, ^ ... #same errors previous [xiaobai@xiaobai cogl]$
first step, recognize missing type name coglonscreen:
[xiaobai@xiaobai cogl]$ gcc -pthread -i/usr/include/cogl -i/usr/include/gdk-pixbuf-2.0 -i/usr/include/libpng16 -i/usr/include/libdrm -i/usr/include/glib-2.0 -i/usr/lib64/glib-2.0/include -lcogl -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lwayland-egl -lwayland-client -lgbm -ldrm -lwayland-server -legl -lx11 -lxext -lxdamage -lxfixes -lxcomposite -lxrandr -lglib-2.0 hello.c hello.c:45:17: error: unknown type name ‘coglonscreen’ frame_event_cb (coglonscreen *onscreen, ^ hello.c:46:17: error: unknown type name ‘coglframeevent’ coglframeevent event, ^
now know coglonscreen supposed located somewhere, tried search "coglonscreen" keyword inside include dir:
[xiaobai@xiaobai cogl]$ grep -rni coglonscreen /usr/include/cogl/cogl/* /usr/include/cogl/cogl/cogl-context.h:250: * @cogl_feature_id_buffer_age: available if age of #coglonscreen /usr/include/cogl/cogl/cogl-display.h:91: * @onscreen_template: #coglonscreentemplate /usr/include/cogl/cogl/cogl-display.h:130: coglonscreentemplate *onscreen_template); /usr/include/cogl/cogl/cogl-display.h:149: * @onscreen_template: template creating #coglonscreen framebuffers /usr/include/cogl/cogl/cogl-display.h:151: * specifies template creating #coglonscreen framebuffers. /usr/include/cogl/cogl/cogl-display.h:153: * depending on system, constraints creating #coglonscreen /usr/include/cogl/cogl/cogl-display.h:164: coglonscreentemplate *onscreen_template); /usr/include/cogl/cogl/cogl-framebuffer.h:79: * there 2 kinds of framebuffer in cogl, #coglonscreen /usr/include/cogl/cogl/cogl-framebuffer.h:85: * rendering #coglonscreen framebuffer /usr/include/cogl/cogl/cogl-framebuffer.h:89: * looking @ #coglonscreen , #cogloffscreen constructor /usr/include/cogl/cogl/cogl-framebuffer.h:1657: * implicitly discard when finish rendering #coglonscreen /usr/include/cogl/cogl/cogl-frame-info.h:80: * gets frame counter #coglonscreen corresponds /usr/include/cogl/cogl/cogl-gles2.h:198: * #cogloffscreen framebuffers (rendering #coglonscreen /usr/include/cogl/cogl/cogl-kms-display.h:48: * #coglonscreen swap_buffers request. applications support /usr/include/cogl/cogl/cogl-onscreen.h:52:typedef struct _coglonscreen coglonscreen; ...
the last line above shown "cogl-onscreen.h" have coglonscreen defined. search cogl-onscreen.h:
[xiaobai@xiaobai cogl]$ grep -rni 'cogl-onscreen.h' /usr/include/cogl/cogl/* /usr/include/cogl/cogl/cogl.h:133:#include <cogl/cogl-onscreen.h> [xiaobai@xiaobai cogl]$
vi /usr/include/cogl/cogl/cogl.h , search "cogl-onscreen.h" keyword:
... /* * 2.0 api that's compatible 1.x api... */ #if defined (cogl_enable_experimental_api) #include <cogl/cogl-swap-chain.h> #include <cogl/cogl-renderer.h> #include <cogl/cogl-output.h> #include <cogl/cogl-display.h> #include <cogl/cogl-context.h> #include <cogl/cogl-buffer.h> #include <cogl/cogl-pixel-buffer.h> #include <cogl/cogl-vector.h> #include <cogl/cogl-euler.h> #include <cogl/cogl-quaternion.h> #include <cogl/cogl-texture-2d.h> #include <cogl/cogl-texture-2d-gl.h> #include <cogl/cogl-texture-rectangle.h> #include <cogl/cogl-texture-3d.h> #include <cogl/cogl-texture-2d-sliced.h> #include <cogl/cogl-sub-texture.h> #include <cogl/cogl-atlas-texture.h> #include <cogl/cogl-meta-texture.h> #include <cogl/cogl-primitive-texture.h> #include <cogl/cogl-index-buffer.h> #include <cogl/cogl-attribute-buffer.h> #include <cogl/cogl-indices.h> #include <cogl/cogl-attribute.h> #include <cogl/cogl-primitive.h> #include <cogl/cogl-depth-state.h> #include <cogl/cogl-pipeline.h> #include <cogl/cogl-pipeline-state.h> #include <cogl/cogl-pipeline-layer-state.h> #include <cogl/cogl-snippet.h> #include <cogl/cogl-framebuffer.h> #include <cogl/cogl-onscreen.h> ...
on top got "#if defined (cogl_enable_experimental_api)". know have give cogl_enable_experimental_api defined in order include cogl-onscreen.h.
search again "cogl_enable_experimental_api" keyword:
#ifdef cogl_enable_experimental_2_0_api #ifndef cogl_enable_experimental_api #define cogl_enable_experimental_api #endif #endif
that's end, need add -d cogl_enable_experimental_2_0_api:
$ gcc -d cogl_enable_experimental_2_0_api -o hello hello.c `pkg-config --cflags --libs cogl-2.0-experimental`
available options pkg-config can figure out autocomplete:
[xiaobai@xiaobai cogl]$ pkg-config --cflags --libs cogl-[press tab] cogl-1.0 cogl-pango-1.0 cogl-path-2.0-experimental cogl-2.0-experimental cogl-pango-2.0-experimental cogl-gl-1.0 cogl-path-1.0 [xiaobai@xiaobai cogl]$
Comments
Post a Comment