使用 gcc,我无法获得第 3 方库开罗链接/编译 [英] Using gcc, I am unable to get 3rd party library, Cairo, to link/compile

查看:26
本文介绍了使用 gcc,我无法获得第 3 方库开罗链接/编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显示的错误是针对未定义符号的,不是我从示例中复制的 Cairo 函数,而是我猜测的内部函数.我环顾四周并尝试使用 $(pkg-config --cflags --libs cairo),从使用终端的常见在线示例中逐字逐句.

The errors that show up are for undefined symbols, not the Cairo functions I copied from the example, but what I guess are internal functions. I have looked around and tried using $(pkg-config --cflags --libs cairo), verbatim from a common online example using the terminal.

我在使用 EXPORT=(我的 cairos .ps 文件路径)后尝试过.

I tried that after using EXPORT=(my path to cairos .ps file).

我目前在链接器设置中的 CodeBlocks链接库"中有一个选项:/usr/lib/x86-linux-gnu/libcairo.a

I currently have one option in CodeBlocks 'Link Libraries' in the linker settings: /usr/lib/x86-linux-gnu/libcairo.a

此外,我的编译器选项中有 /usr/include/cairo.

Also, I have /usr/include/cairo in my compiler options.

错误:

/usr/lib/x86_64-linux-gnu/libcairo.a(cairo-image-source.o)||在函数_cairo_image_source_finish':|(.text+0x1c)||未定义引用pixman_image_unref'|

/usr/lib/x86_64-linux-gnu/libcairo.a(cairo-image-source.o)||In function _cairo_image_source_finish':| (.text+0x1c)||undefined reference topixman_image_unref'|

另外还有 50 个喜欢它.

Plus 50 more like it.

从以下生成,main.c:

Which are generated from the following, main.c:

include cairo.h (with # and <>)

int main()
{

    cairo_surface_t *surface =
        cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
    cairo_t *cr =
        cairo_create (surface);

    cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size (cr, 32.0);
    cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
    cairo_move_to (cr, 10.0, 50.0);
    cairo_show_text (cr, "Hello, world");

    cairo_destroy (cr);
    cairo_surface_write_to_png (surface, "hello.png");
    cairo_surface_destroy (surface);

    return 0;
}

任何帮助修复和理解正在发生的事情将不胜感激.谢谢.

Any help fixing and understanding what's going on would be greatly appreciated. Thanks.

推荐答案

所以这个问题的解决方案如下:

So the solution for this problem was as follows:

对所有正确的包含使用 pkg-config.通过添加以下内容自动执行此操作:

pkg-config --cflags --libs cairo(用`"包围,在波浪号键上.)

到编译器设置中的其他选项"选项卡.

Use pkg-config for all the correct includes. Do so automatically by adding:

pkg-config --cflags --libs cairo (surrounded by " ` ", on the tilde key.)

to my "Other options" tab in the compiler settings.

我对链接器的其他选项"选项卡做了同样的事情:

pkg-config --libs cairo(也被`"包围,重音符号)

I did the same for the linker "Other options" tab using:

pkg-config --libs cairo (also surrounded by " ` ", the accent grave)

现在我没有错误地构建和编译,但是当我运行它时,我只看到一个空的控制台窗口:/

Now I build and compile with no errors, but when I run it, I don't see anything but an empty console window : /

这篇关于使用 gcc,我无法获得第 3 方库开罗链接/编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆