Here's simple test to get started writing code that uses Cairo on MSYS2:
#include <cairo.h>
int main() {
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 300, 300);
cairo_t *cr = cairo_create(surface);
cairo_set_line_width(cr, 10.0);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_move_to(cr, 10.0, 10.0);
cairo_line_to(cr, 100.0, 100.0);
cairo_stroke(cr);
cairo_destroy(cr);
cairo_surface_write_to_png(surface, "c.png");
cairo_surface_destroy(surface);
return 0;
}
This code builds and executes properly on Darwin/MacPorts with this command:
$ gcc c.c -o c `pkg-config cairo --libs --cflags`
Under Win8/MSYS2, I have installed the mingw-w64-x86_64-cairo
package. The same gcc
build command succeeds, but running the resulting executable results in this error:
C:/msys64/path/to/c.exe: error while loading shared libraries: libcairo-2.dll: cannot open shared object file: No such file or directory
I have tried to find libcairo-2.dll
inside of MSYS2, but I don't see anything. A Google search doesn't get me any closer.
I suspect that this is part of the learning curve of MSYS2 development; what am I missing?
Do you have /mingw64/bin
in your PATH
environment variable when running the compiled executable?
libcairo-2.dll
(and lots of other .dll files) lives in /mingw64/bin
.
This is already solved in the MinGW shell, which is not the same as the MSYS2 shell. Both are there in the start menu.