0

I am trying to compile a glib application in windows 10, but i keep getting this error:

In file included from C:\Users\DamŔa\Desktop\C\glib-2.0/glibconfig.h:9,
                 from C:\Users\DamŔa\Desktop\C\glib-2.0/glib/gtypes.h:32,
                 from C:\Users\DamŔa\Desktop\C\glib-2.0/glib/galloca.h:32,
                 from C:\Users\DamŔa\Desktop\C\glib-2.0/glib.h:30,
                 from main.c:3:
C:\Users\DamŔa\Desktop\C\glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
C:\Users\DamŔa\Desktop\C\glib-2.0/glib/gmacros.h:818:31: error: static assertion failed: "Expression evaluates to false"
 #define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
                               ^~~~~~~~~~~~~~
C:\Users\DamŔa\Desktop\C\glib-2.0/glib/gmacros.h:818:31: note: in definition of macro 'G_STATIC_ASSERT'
 #define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")

while trying to compile it with this command:

gcc -I"C:\Users\Damča\Desktop\C\glib-2.0" main.c

I did some research and found out that it could be because i am not using pkg-config, but it doesn't work on windows, because it cant find the file glib-2.0.pc.

so, how can i compile it withnout pkg-config? or how do i make it work on windows?

Damca
  • 50
  • 1
  • 8
  • Are you compiling targeting Windows (native compilation) or Linux (cross-compilation)? – fpiette Jun 29 '21 at 17:07
  • @fpiette yes, i am targeting windows. – Damca Jun 29 '21 at 17:09
  • OK, then are you using [GTK for Windows](https://www.gtk.org/docs/installations/windows)? – fpiette Jun 29 '21 at 17:11
  • @fpiette nope, but i will try it out. Thanks for the tip – Damca Jun 29 '21 at 17:28
  • @fpiette i tried executing the command `gcc main.c \`pkg-config glib-2.0 --cflags --libs glib-2.0\`` using MSYS, and got an error saying thet the package glib-2.0 was not found. – Damca Jun 29 '21 at 18:26
  • The GLib source code for Linux won't work for Windows. Use the [Windows version](https://www.gtk.org/docs/installations/windows) and try again. – fpiette Jun 29 '21 at 18:45
  • It's possible that the difference between `C:\Users\DamŔa\Desktop` and `C:\Users\Damča\Desktop` will confuse some compilers. – Tim Randall Jun 29 '21 at 19:02
  • @fpiette installing those packages and setting env. variable `PKG_CONFIG_PATH` to the .pc file solved my problem. Thank you very much for your help. – Damca Jun 29 '21 at 19:54
  • @TimRandall it is possible but it didn't cause any problems yet, but changing it wouldn't be a bad idea. – Damca Jun 29 '21 at 19:56
  • Try out this website [here](https://stackoverflow.com/questions/1450445/installing-gtk-and-compiling-using-gcc-under-windows#:~:text=Whenever%20you%20want%20to%20compile%20something%20that%20uses,to%20compile%20from%20within%20a%20normal%20command%20prompt.) – ADBeveridge Jun 29 '21 at 20:18
  • @fpiette of course :) – Damca Jul 01 '21 at 19:21

1 Answers1

1

The GLib source code for Linux won't work for Windows. Use the Windows version and try again. Set the environment variable PKG_CONFIG_PATH to the .pc file

fpiette
  • 11,983
  • 1
  • 24
  • 46