Code::Blocks Forums

User forums => Help => Topic started by: Denis Mungle on June 03, 2021, 01:42:16 am

Title: mingw missing libs
Post by: Denis Mungle on June 03, 2021, 01:42:16 am
This problem keeps happening where i have the path of the variables correctly placed in the compiler settings but i cant seem to find the   -ldwmapi anywhere (this is the message):

 gcc.exe  -o bin\Debug\GTK_Demo.exe obj\Debug\main.o  -LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl   
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
collect2.exe: error: ld returned 1 exit status

I'm kinda new to this ide and how to use it properly any ideas? The C:/msys64/mingw64/bin/../lib path as the -ldwmapi libs on it.
I have applied `pkg-config --cflags gtk+-3.0` to other compiler options and in the linker `pkg-config --libs gtk+-3.0`
Title: Re: mingw missing libs
Post by: AndrewCot on June 03, 2021, 05:07:55 am
This issue is not with CB, but with the packages you are trying to build. I suggest google "libdwmapi.a" and have a read as this has occurred before and hopefully some of the results have a solution for you. Some of the results are old, so be aware of this.

This page could be the one to start with:
https://packages.msys2.org/package/msys2-w32api-runtime?repo=msys&variant=x86_64
Title: Re: mingw missing libs
Post by: stahta01 on June 03, 2021, 05:16:38 am
Is dwmapi an DLL or a static library?

If static library, I have always used a full path to the library because I have never gotten -llibname to work with an static MSys2 library.

Edit: It appears to be a windows system DLL and not an MSys2 DLL, I have not had this problem. So, my solution may or may not work with an import library to an system DLL.

Edit2: If you attach your CB project and the c/c++ source files with the header files (as a single zip or 7z file),  I can try to build it. I have MSys2 installed.

Tim S.
Title: Re: mingw missing libs
Post by: stahta01 on June 03, 2021, 06:05:35 am
Could not duplicate problem on my computer.

My computer uses a non standard MSys2 installation; but, that just results in a different path displayed.
My MSys2 installation used is installed in "C:\building\msys64" instead of normal "C:\msys64".

I am guessing a bad compiler toolchain setting is the cause.

Code
-------------- Clean: Release in gtk_manual_setup (compiler: GNU GCC Compiler)---------------

Cleaned "gtk_manual_setup - Release"

-------------- Build: Release in gtk_manual_setup (compiler: GNU GCC Compiler)---------------

x86_64-w64-mingw32-gcc.exe -Wall -IC:/building/msys64/mingw64/bin/../include/gtk-3.0 -IC:/building/msys64/mingw64/bin/../include/pango-1.0 -IC:/building/msys64/mingw64/bin/../include -IC:/building/msys64/mingw64/bin/../include/glib-2.0 -IC:/building/msys64/mingw64/bin/../lib/glib-2.0/include -IC:/building/msys64/mingw64/bin/../include/harfbuzz -IC:/building/msys64/mingw64/bin/../include/freetype2 -IC:/building/msys64/mingw64/bin/../include/libpng16 -mms-bitfields -IC:/building/msys64/mingw64/bin/../include/fribidi -IC:/building/msys64/mingw64/bin/../include/cairo -IC:/building/msys64/mingw64/bin/../include/lzo -IC:/building/msys64/mingw64/bin/../include/pixman-1 -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -IC:/building/msys64/mingw64/bin/../include/gdk-pixbuf-2.0 -mms-bitfields -mms-bitfields -mms-bitfields -IC:/building/msys64/mingw64/bin/../include/atk-1.0 -mms-bitfields -mms-bitfields -mms-bitfields -pthread -mms-bitfields -O2  -c C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c -o obj/Release/main.o
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c: In function 'main':
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:34:3: warning: 'gtk_vbox_new' is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
   34 |   vbox = gtk_vbox_new (TRUE, 6);
      |   ^~~~
In file included from C:/building/msys64/mingw64/include/gtk-3.0/gtk/gtk.h:286,
                 from C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:2:
C:/building/msys64/mingw64/include/gtk-3.0/gtk/deprecated/gtkvbox.h:61:13: note: declared here
   61 | GtkWidget * gtk_vbox_new      (gboolean homogeneous,
      |             ^~~~~~~~~~~~
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:37:3: warning: 'gtk_button_new_from_stock' is deprecated: Use 'gtk_button_new_with_label' instead [-Wdeprecated-declarations]
   37 |   button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO);
      |   ^~~~~~
In file included from C:/building/msys64/mingw64/include/gtk-3.0/gtk/gtk.h:54,
                 from C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:2:
C:/building/msys64/mingw64/include/gtk-3.0/gtk/gtkbutton.h:103:16: note: declared here
  103 | GtkWidget*     gtk_button_new_from_stock    (const gchar    *stock_id);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:37:3: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
   37 |   button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO);
      |   ^~~~~~
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:41:3: warning: 'gtk_button_new_from_stock' is deprecated: Use 'gtk_button_new_with_label' instead [-Wdeprecated-declarations]
   41 |   button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
      |   ^~~~~~
In file included from C:/building/msys64/mingw64/include/gtk-3.0/gtk/gtk.h:54,
                 from C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:2:
C:/building/msys64/mingw64/include/gtk-3.0/gtk/gtkbutton.h:103:16: note: declared here
  103 | GtkWidget*     gtk_button_new_from_stock    (const gchar    *stock_id);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/stahta01/Documents/test/gtk_manual_setup/main.c:41:3: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
   41 |   button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
      |   ^~~~~~
x86_64-w64-mingw32-gcc.exe  -o bin/Release/gtk_manual_setup.exe obj/Release/main.o  -LC:/building/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -s 
Output file is bin\Release\gtk_manual_setup.exe with size 19.00 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 5 warning(s) (0 minute(s), 1 second(s))
 
Title: Re: mingw missing libs
Post by: stahta01 on June 03, 2021, 06:10:41 am
My 64 bit toolchain setting for MSys2 installed in "C:\building\msys64"

Compiler installation directory: C:\building\msys64\mingw64
C compiler: x86_64-w64-mingw32-gcc.exe
C++ compiler: x86_64-w64-mingw32-g++.exe
Dyn. linker: x86_64-w64-mingw32-g++.exe
Static linker: ar.exe

The "/usr/bin" is not normally needed and you should only add it if you need it. I use the sh.exe in some projects and they need it.
Additional paths: $(TARGET_COMPILER_DIR)/../usr/bin

Tim S.



Title: Re: mingw missing libs
Post by: Denis Mungle on June 03, 2021, 04:56:35 pm
Here are my MinGW and CB project .zip , i still cant understand why the -ldwmapi lib cant be found. The compiler settings and linker settings are still the same as i previously said, the compiler installation dir is the auto-detected C:\MinGW. Do i have to add a full path to the lib?

Also when i write in the command line pkg-config --libs gtk+-3.0
-LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl

It shows the right lib, but i dont know how to access that directory.
Thx
Title: Re: mingw missing libs
Post by: stahta01 on June 03, 2021, 05:06:17 pm
Rename or delete the folder "C:\MinGW"!
Having this folder messes up the CB auto-detect and makes some other MinGW GCC compilers  not work right.
Edit: Other folders that are bad to have include "C:\MinGW32" or "C:\MinGW64".

You then need to set your CB compiler settings to use the MSys2 MinGW64 toolchain.
You need to decide if you wish to use 64 or 32 bit MinGW libraries.
Then you can try to use the MSys2 MinGW64 libraries.

Tim S.
Title: Re: mingw missing libs
Post by: Denis Mungle on June 03, 2021, 05:15:00 pm
Thx its working now :) !!