GCC, GTK on Windows10 ld.exe: cannot find -ldwmapi

  c++, gcc, mingw, msys2

I’m pretty new to all this so excuse me if I put useless info, or forget useful ones on this post.

I’m trying to code a GUI with GTK in C on Windows10. So I have installed Msys2 in order to use GTK. In Msys2 I have installed the basic pkgs and all the GTK pkgs. Then on VScode I have installed an extension to link external libraries

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:msys64mingw32includegtk-3.0",
                "C:msys64mingw32includeglib-2.0",
                "C:msys64mingw32includepango-1.0",
                "C:msys64mingw32includeharfbuzz",
                "C:msys64mingw32includecairo",
                "C:msys64mingw32includegdk-pixbuf-2.0",
                "C:msys64mingw32includeatk-1.0"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "D:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.29.30133binHostx64x64cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

Here’s what it looks like, but I believe this doesn’t really matter as I manually compile on the powershell.

Here’s how I compile my file (in a .bat file):

gcc main.c -o mikey.exe -LC:msys64mingw32libgtk-3.0 -Wl,-luuid -LC:msys64mingw32lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -ldwmapi -lwinmm -lsetupapi -lcfgmgr32 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lharfbuzz -lcairo -lgobject-2.0 -lglib-2.0 -lintl -IC:msys64mingw32includegtk-3.0 -IC:msys64mingw32includeglib-2.0 -IC:msys64mingw32includepango-1.0 -IC:msys64mingw32includeharfbuzz -IC:msys64mingw32includecairo -IC:msys64mingw32includegdk-pixbuf-2.0 -IC:msys64mingw32includeatk-1.0  

All the -l args come from:

C:msys64mingw32binpkg-config.exe --libs gtk+-3.0

This looks bad because I failed at trying to put pkg-config on PATH or wtv x)

And the -I were consecutively asked by the compiler.

Sooooo now I get the following error when compiling:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
collect2.exe: error: ld returned 1 exit status

I know that the dwmapi.dll exists in my System32 folder, but I don’t even know if it the subject here.

I am completly lost tbh

My main.c if necessary:

#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
    GtkWidget *window;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    gtk_widget_show(window);

    gtk_main();

    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT