I am trying to test out a few simple Cairo programs, but I am having trouble figuring how to include the source files. I have installed the Cairo library - it's just a question of how to let gcc know...
Are there any other components of the installation I should be aware of? (I just did 'make install' to install the library)
I am trying to compile like this:
$ gcc cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/
My cairoTest.c file starts out with:
include <cairo.h>
gcc is finding cairo.h, but it gives the following error message. I think it is not linking to the .dylib files correctly, but I'm not sure. I'm still new to compiling/linking.
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
What should I be doing differently to include the Cairo library in my compilation?
Thanks,
Try to compile with
gcc -Wall -g cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/ -lcairo -o cairoTest
(but you probably need other libraries, perhaps thru $(pkg-config --cflags --libs cairo)
or similar)
And your file should start with
#include <cairo.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With