我的环境是 Fedora 21,我从http://www.cogl3d.org/hello.html玩 hello 教程,它显示:
构建示例
如果将上述代码保存到名为 hello.c 的文件中,则可以按如下方式编译示例:
gcc -o 你好你好.c
pkg-config --cflags --libs cogl2 glib-2.0
但是我在哪里可以找到 cogl2 库?
如果我不包括 cogl 库:
[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]$
我试过dnf search cogl
但只有cogl,没有cogl2这样的东西:
[xiaobai@xiaobai cogl]$ dnf search cogl
[sudo] password for xiaobai:
================================================================= N/S Matched: cogl ==================================================================
cogl.x86_64 : A library for using 3D graphics hardware to draw pretty pictures
cogl.i686 : A library for using 3D graphics hardware to draw pretty pictures
cogl-doc.noarch : Documentation for cogl
cogl-devel.x86_64 : cogl development environment
cogl-devel.i686 : cogl development environment
[xiaobai@xiaobai cogl]$
我也搜索 cogl.h,也没有这样的 cogl2:
[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]$
我无法使用 pkg-config 既找不到 cogl 也找不到 cogl2:
[xiaobai@xiaobai cogl]$ pkg-config --cflags --libs cogl2 cogl
Package cogl2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `cogl2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cogl2' found
Package cogl was not found in the pkg-config search path.
Perhaps you should add the directory containing `cogl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cogl' found
[xiaobai@xiaobai cogl]$
所以我只是尝试了cogl:
$ gcc -o hello hello.c
pkg-config --cflags --libs glib-2.0
-I/usr/include/cogl/
,它显示了很多错误信息:
[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 from integer without a cast
data.ctx = cogl_context_new (NULL, &error);
^
hello.c:92:13: warning: assignment makes pointer from integer without a cast
data.fb = cogl_onscreen_new (data.ctx, 640, 480);
^
hello.c:98:19: warning: assignment makes pointer from integer without a cast
data.pipeline = cogl_pipeline_new (data.ctx);
^
hello.c:100:17: warning: assignment makes pointer from integer without a cast
cogl_source = cogl_glib_source_new (data.ctx, G_PRIORITY_DEFAULT);
^
hello.c:105:39: error: ‘frame_event_cb’ undeclared (first use in this function)
frame_event_cb,
^
hello.c:105:39: note: each undeclared identifier is reported only once for each function it appears in
hello.c:110:39: error: ‘dirty_cb’ undeclared (first use in this function)
dirty_cb,
^
[xiaobai@xiaobai cogl]$
非常感谢任何帮助。
[更新]我尝试了@CYB3R 解决方案,但仍然没有运气:
[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 like previous
[xiaobai@xiaobai cogl]$