Pkg-config --libs gtk + -3.0 problem

Hello everybody

I use Windows and msys64.

I have a problem with pkg-config --libs gtk + -3.0 When I call: pkg-config pkg-config --libs gtk + -3.0 get this list: -LC: / msys64 / mingw64 / 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 -latk-1.0 -lcairo-gobl- lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl. Unfortunately my IDE cannot find the files: -ldwmapi und -Wl.

Thanks a lot

/mingw64/x86_64-w64-mingw32/lib/libdwmapi.a

"-Wl,-luuid" tells gcc to pass the option "-luuid" directly to the linker (ld.exe).

Thanks Grep King, ldwmapi is now found
What do I have to do with -Wl, -luuid? Are they compiler flags?

It’s a single option; there is no space after the comma. “-Wl,-luuid” does exactly the same thing that “-luuid” does (I don’t know why the authors of the GDK library didn’t use the simpler version). You want your IDE to look for that library.

I can’t answer your question because it depends on how your IDE can be configured.

My IDE has now found “-Wl, -luuid”.
Unfortunately there is a new problem. I now get the following error message:

|| === Build: Debug in GTK_Test_Projekt (compiler: GNU GCC Compiler) === |
obj \ Debug \ main.o: main.c || undefined reference to `g_print '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_application_window_new '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_window_get_type '|
obj \ Debug \ main.o: main.c || undefined reference to `g_type_check_instance_cast '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_window_set_title '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_window_get_type '|
obj \ Debug \ main.o: main.c || undefined reference to `g_type_check_instance_cast '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_window_set_default_size '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_button_box_new '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_container_get_type '|
obj \ Debug \ main.o: main.c || undefined reference to `g_type_check_instance_cast '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_container_add '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_button_new_with_label '|
obj \ Debug \ main.o: main.c || undefined reference to `g_signal_connect_data '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_widget_destroy '|
obj \ Debug \ main.o: main.c || undefined reference to `g_signal_connect_data '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_container_get_type '|
obj \ Debug \ main.o: main.c || undefined reference to `g_type_check_instance_cast '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_container_add '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_widget_show_all '|
obj \ Debug \ main.o: main.c || undefined reference to `gtk_application_new '|
obj \ Debug \ main.o: main.c || undefined reference to `g_signal_connect_data '|
obj \ Debug \ main.o: main.c || undefined reference to `g_application_get_type '|
obj \ Debug \ main.o: main.c || undefined reference to `g_type_check_instance_cast '|
obj \ Debug \ main.o: main.c || undefined reference to `g_application_run '|
obj \ Debug \ main.o: main.c || undefined reference to `g_object_unref '|
|| error: ld returned 1 exit status |
|| === Build failed: 27 error (s), 0 warning (s) (0 minute (s), 1 second (s)) === |

I used this code: https://www.gtk.org/docs/getting-started/hello-world/

I gave the pkg-config --cflags gtk +-3.0 to the compiler. Where’s the problem?

You need to give pkg-config --libs gtk+-3.0 to the linker as well.

I have made. I received the following error message: ld.exe cannot find -ldwmapi

Grep King suggested the following directory for -ldwmapi: /mingw64/x86_64-w64-mingw32/lib/libdwmapi.a

Now the error message no longer comes from
-ldwmapi.

Is it maybe the wrong -ldwmapi?

Have attached a picture, maybe it will help. You can also see that
-ldwmapi was not found.

The build message said that there were 2 errors. What is the other error?

One of the errors is: ld.exe || cannot find -ldwmapi |
The other error is: || error: ld returned 1 exit status |

Maybe build log can help:

The “GNU GCC Compiler” profile doesn’t know about MSYS2 – none of the compiler selections does. You must create a new one for MSYS2:

  1. Go to Settings -> Compiler... -> Global compiler settings.
  2. Select the “Cygwin GCC” compiler.
  3. Make a copy of it. Name the new one “mingw64 GCC”. Set it as the default.
  4. Go to the “Toolchain executables” tab. Point the “Compiler’s installation directory” to "C:\msys64\mingw64". Add "C:\msys64\usr\bin" to “Additional Paths”.
  5. Go to your project’s Build options.... Click on the project’s name in the left box.
  6. Select the “mingw64 GCC” compiler. Click OK. When Code::Blocks asks, “Do you want to use the same compiler for all the project’s build targets too?”, click “Yes”.

Thank you very much greg-king it works now!