I'm using macOS Catalina (v10.15.7) to compile the following example code from gtkmm's online book:
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
It compiles fine for macOS, but if I try to compile it for Windows using:
x86_64-w64-mingw32-g++ -o app.exe main.cpp -std=c++11 `pkg-config gtkmm-3.0 --cflags --libs`
Besides various warnings, I get the following errors for which I couldn't find almost any solutions on Google and Stack Overflow:
/usr/local/Cellar/glib/2.66.2_1/include/glib-2.0/gio/gcredentials.h:75:1: error: 'uid_t' does not name a type; did you mean 'pid_t'?
75 | uid_t g_credentials_get_unix_user (GCredentials *credentials,
| ^~~~~
| pid_t
/usr/local/Cellar/glib/2.66.2_1/include/glib-2.0/gio/gcredentials.h:79:52: error: 'uid_t' has not been declared
79 | uid_t uid,
| ^~~~~
/usr/local/Cellar/glibmm/2.64.5/include/giomm-2.4/giomm/credentials.h:243:3: error: 'uid_t' does not name a type; did you mean 'pid_t'?
243 | uid_t get_unix_user();
| ^~~~~
| pid_t
/usr/local/Cellar/glibmm/2.64.5/include/giomm-2.4/giomm/credentials.h:264:22: error: 'uid_t' has not been declared
264 | bool set_unix_user(uid_t uid);
| ^~~~~
Any help is much appretiated.
From an element chat room, I was told that the pkg-config
on macOS seems to be using the macOS version of its libraries for compiling. Even if compile-time errors like uid_t
are resolved, the libraries wouldn't be able to link properly.
In the end, it was much easier to compile the executable directly on a Windows machine.
pacman -Syu
gcc
& mingw
packages:pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gcc
gtkmm
libraries:pacman -S mingw-w64-i686-gtkmm3
pacman -S mingw-w64-x86_64-gtkmm3
pkg-config
:pacman -S pkg-config
mingw64.exe
in C:/msys64
and navigate to the directory where the source code exists.The final cavier, compile your source code using:
g++ -std=c++11 hello.cpp -o myApp $(pkg-config gtkmm-3.0 --cflags --libs | sed 's/ -I/ -isystem /g')