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

问题描述

显示的错误是未定义的符号,而不是我从示例复制的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'Link Libraries'目前有一个选项:
/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'|

这是由以下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,我无法获得第三方库,Cairo,链接/编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-17 01:29