Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compiling cairo for x86_64-w64 with mingw

I have an application that links again SDL and cairo that I would like to cross-compile on ubuntu for win64. I used this excellent blog post to get SDL cross compiling and I've used another blog post to cross-compile zlib, libpng and libpixman.

However, I now 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 something is wrong with the cairo library that I cross-compiled. How should I go about diagnosing the problem?

like image 318
hertzsprung Avatar asked Oct 20 '22 11:10

hertzsprung


1 Answers

Looking at your Makefile it appears as though your are using normal pkg-config for discovering your Cairo libs. CAIRO_LDFLAGS := $(shell $(PKG_CONFIG) cairo --libs). This will find the path to your host libraries, which is presumably a different architecture than the target. An architecture mismatch like that can really cause strange problems with the linker. I believe you should be looking for something like usr/x86_64-w64-mingw32/bin/pkg-config.

Other things to try;

Run the compilation commands manually, as the makefile could be suppressing output.

Also, when running the command, add the -v flag to the command line to get the verbose output to better figure out where the issue is.

like image 51
Joshua Rahm Avatar answered Oct 30 '22 16:10

Joshua Rahm