0

I am trying to compile the zetcode lines on Windows 10 using msys64.

I use the following compilation command:

gcc example.c -o example `pkg-config --cflags --libs cairo gtk+-3.0`

and get the following error:

-bash: pkg-config: command not found
example.c:1:19: fatal error: cairo.h: No such file or directory
 #include <cairo.h>

However I did pacman -S mingw-w64-i686-cairo before and the installation was successful. When I type **pacman -Ss mingw-w64-i686-cairo ** I get the following:

mingw32/mingw-w64-i686-cairo 1.15.2-4 [installed]
    Cairo vector graphics library (mingw-w64)

When I run gcc -v I get:

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/5.3.0/lto-wrapper.exe Target: x86_64-pc-msys Configured with: /msys_scripts/gcc/src/gcc-5.3.0/configure --build=x86_64-pc-msys --prefix=/usrable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --diso --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libg --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-cith-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible Thread model: posix gcc version 5.3.0 (GCC)

Last but not least, If I follow the instruction on this website I can compile the lines code. However, GTK3 version provided is very old and cannot run newer code.

The paths to Cairo.h are:

C:\MinGW\include\cairo for the outdated (but working) GTK+3 install

and

C:\msys64\mingw32\include\cairo

and

C:\msys64\mingw64\include\cairo for the newer (but not working) GTK3 install using msys64

Which directory is MSYS64 trying to find the Cairo library?

PintoDoido
  • 1,011
  • 16
  • 35
  • Have you made sure the paths where the compiler looks for includes are correct? –  May 03 '17 at 09:17
  • The folder C:\msys64\mingw64\include\cairo does exist. How do I check where the compiler looks for includes? – PintoDoido May 03 '17 at 11:31
  • `gcc -v`, I believe. And `gcc -I dir/ect/ory` to add a directory to search for includes. –  May 03 '17 at 11:58
  • Cannot make sense of the **gcc -v** output! Do you have a better idea? – PintoDoido May 03 '17 at 16:14
  • How are you compiling? What are your arguments to the compiler? The standard way to compile a single C file that uses cairo is `gcc foo.c $(pkg-config --cflags --libs cairo)`. No idea if calling pkg-config inline like this works on Windows 10 with msys64. The idea is: Add the output of `pkg-config --cflags --libs cairo` to the compiler arguments. – Uli Schlachter May 05 '17 at 07:46
  • If I run **gcc example.c $(pkg-config --cflags --libs cairo)** I still get the same ** fatal error: cairo.h: No such file or directory** error – PintoDoido Jun 26 '17 at 10:00

1 Answers1

0

You showed two messages. Lines two and three came from the compiler. The first line came from the shell. That first bug caused the second bug. It says that the pkg-config command doesn't exist. You need to install its package. Use this command (it installs other useful packages, too):

pacboy sync base-devel

(You don't need to name cairo in the pkg-config command; gtk+-3.0 names the packages that it needs.)

Greg King
  • 36
  • 3