0

I developed a program on linux which uses the gtkmm library. The code compiles successfully on linux platforms. I am attempting to compile it on Windows 10 using MSYS2 to obtain gcc and the gtkmm library.

During compilation, I receive errors while compiling the giomm dependency of gtkmm. It invokes dbusmessage.h, and I receive the following compilation error:

$ g++ main.cpp source/ControlWidget.cpp source/ControlWidget.h source/LaneWidget.cpp source/LaneWidget.h source/NameDialogue.cpp source/NameDialogue.h source/mainwindow.cpp source/mainwindow.h source/rs232.c source/rs232.h $(pkg-config --cflags --libs gtkmm-4.0) -o test.exe
In file included from C:/msys64/mingw64/include/windows.h:71,
                 from source/rs232.h:56,
                 from source/ControlWidget.h:14,
                 from source/mainwindow.h:14,
                 from main.cpp:1:
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:90:3: error: expected identifier before num
eric constant
   90 |   ERROR,
      |   ^~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:90:3: error: expected '}' before numeric co
nstant
In file included from C:/msys64/clang64/include/giomm-2.68/giomm/dbusmethodinvocation.h:26,
                 from C:/msys64/clang64/include/giomm-2.68/giomm/dbusconnection.h:29,
                 from C:/msys64/clang64/include/giomm-2.68/giomm/application.h:37,
                 from C:/msys64/clang64/include/gtkmm-4.0/gtkmm/application.h:32,
                 from main.cpp:2:
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:86:1: note: to match this '{'
   86 | {
      | ^
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:90:3: error: expected unqualified-id before
 numeric constant
   90 |   ERROR,
      |   ^~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:279:1: error: expected declaration before
}' token
  279 | } // namespace Gio
      | ^
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:286:34: error: 'CapabilityFlags' is not a m
ember of 'Gio::DBus'; did you mean 'Gio::CapabilityFlags'?
  286 | class GIOMM_API Value<Gio::DBus::CapabilityFlags> : public Glib::Value_Flags<Gio::DBus::Capa
bilityFlags>
      |                                  ^~~~~~~~~~~~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:242:12: note: 'Gio::CapabilityFlags' declar
ed here
  242 | enum class CapabilityFlags
      |            ^~~~~~~~~~~~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:286:49: error: template argument 1 is inval
id
  286 | class GIOMM_API Value<Gio::DBus::CapabilityFlags> : public Glib::Value_Flags<Gio::DBus::Capa
bilityFlags>
      |                                                 ^
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:286:89: error: 'CapabilityFlags' is not a m
ember of 'Gio::DBus'; did you mean 'Gio::CapabilityFlags'?
  286 | class GIOMM_API Value<Gio::DBus::CapabilityFlags> : public Glib::Value_Flags<Gio::DBus::Capa
bilityFlags>
      |                                                                                         ^~~~
~~~~~~~~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:242:12: note: 'Gio::CapabilityFlags' declar
ed here
  242 | enum class CapabilityFlags
      |            ^~~~~~~~~~~~~~~
C:/msys64/clang64/include/giomm-2.68/giomm/dbusmessage.h:286:104: error: template argument 1 is inva
lid
  286 | class GIOMM_API Value<Gio::DBus::CapabilityFlags> : public Glib::Value_Flags<Gio::DBus::Capa
bilityFlags>
      |
           ^

I have made sure all of my MSYS2 packages are up to date. Everything is at the latest version.

g++.exe version: 12.2.0 gtkmm version: 4.0

Andrew C
  • 137
  • 2
  • 10
  • Why do both `C:/msys64/mingw64` and `C:/msys64/clang64` show up during compilation? This doesn't look right. Which MSYS2 environment are you running? (as indicated by magenta text in the terminal prompt. Did you customize any environment variables in it? Did you somehow else customize the library search paths? – HolyBlackCat Mar 29 '23 at 21:47
  • I added C:/msys64/clang64 to the pkg-config search path because the gtkmm library installed to that path. I can see how that could cause a problem. – Andrew C Mar 29 '23 at 21:59
  • That's a big no-no. MSYS2 has several flavors, aka [environments](https://www.msys2.org/docs/environments/). Pick one. E.g. if you picked MINGW64, the packages you install must be prefixed with `mingw-w64-x86_64-`, not `mingw-w64-clang-x86_64-` (so you want `mingw-w64-x86_64-gtkmm`). Packages with different prefixes will be ignored. Packages without prefixes may interfere (so don't install plain `gcc`, only `mingw-w64-x86_64-gcc`). Only use unprefixed packages for command-line tools not directly related to compilation (e.g. `make`, `grep`). – HolyBlackCat Mar 29 '23 at 22:45
  • Then start the MSYS2 terminal using the appropriate shortcut for your environment (I believe `MINGW64` is called `MSYS2 MinGW 64-bit`, or something like that). If done correctly, the terminal prompt will say `MINGW64` in magenta letters, and all MINGW64 packages will be added to appropriate env variables. – HolyBlackCat Mar 29 '23 at 22:46

0 Answers0