Cross compiling cairo for x86_64-w64 with mingw

I have an application that binds SDL and cairo again, which I would like to cross-compile on ubuntu for win64. I used this great blog post to get a compilation of SDL cross cards, and I used another blog post to cross compile zlib, libpng and libpixman.

However, now I get a linker error trying to compile my minimal test program :

$ make cairotest.exe 
x86_64-w64-mingw32-gcc -o cairotest.o -c cairotest.c -I/usr/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main -I/home/jshaw/x86_64-w64/include/cairo -I/home/jshaw/x86_64-w64/include/pixman-1 -I/home/jshaw/x86_64-w64/include/libpng16 
x86_64-w64-mingw32-gcc -o cairotest.exe cairotest.o -L/usr/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -L/home/jshaw/x86_64-w64/lib -lcairo 
collect2: error: ld returned 1 exit status
Makefile:13: recipe for target 'cairotest.exe' failed

I should mention that this test program works correctly if I just use SDL2 without any cairo code, so I suspect that something is wrong with the cairo library that I cross-compiled. How do I go about diagnosing a problem?

+4
source share
1 answer

Looking at your Makefile, it seems like you are using the usual one pkg-configto detect your Cairo libs. CAIRO_LDFLAGS := $(shell $(PKG_CONFIG) cairo --libs). This will find a path to your host libraries that is supposedly different from the architecture. This architecture mismatch can actually cause strange problems with the linker. I believe you should look for something like usr/x86_64-w64-mingw32/bin/pkg-config.

Other things to try;

Run compilation commands manually, as the makefile may suppress output.

In addition, when you run the command, add a flag -vto the command line to get detailed output in order to better understand where the problem is.

+2
source

All Articles