我正在尝试测试一些简单的开罗程序,但我无法确定如何包含源文件。我已经安装了Cairo库 - 这只是一个如何让gcc知道的问题......
我应该注意安装的其他任何组件吗? (我刚刚'make install'来安装库)
我正在尝试像这样编译:
$ gcc cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/
我的cairoTest.c文件以:
开头include <cairo.h>
gcc正在查找cairo.h,但它提供了以下错误消息。我认为它没有正确链接到.dylib文件,但我不确定。我还是新编译/链接。
gcc cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/cairo
Undefined symbols for architecture x86_64:
"_cairo_image_surface_create", referenced from:
_main in ccVd9Pet.o
"_cairo_create", referenced from:
_main in ccVd9Pet.o
"_cairo_scale", referenced from:
_main in ccVd9Pet.o
"_cairo_set_line_width", referenced from:
_main in ccVd9Pet.o
"_cairo_set_source_rgb", referenced from:
_main in ccVd9Pet.o
"_cairo_rectangle", referenced from:
_main in ccVd9Pet.o
"_cairo_stroke", referenced from:
_main in ccVd9Pet.o
"_cairo_surface_write_to_png", referenced from:
_main in ccVd9Pet.o
"_cairo_destroy", referenced from:
_main in ccVd9Pet.o
"_cairo_surface_destroy", referenced from:
_main in ccVd9Pet.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [all] Error 1
我应该采取哪些不同的方式将Cairo库包含在我的编辑中?
谢谢,
答案 0 :(得分:7)
尝试使用
进行编译 gcc -Wall -g cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/ -lcairo -o cairoTest
(但您可能需要其他库,可能是$(pkg-config --cflags --libs cairo)
或类似的)
您的文件应以
开头 #include <cairo.h>