Hello!
The program compiles normally without static linking. When I try to compile programs with static layout in release mode (I have attached a screenshot of the settings), I receive messages:
||=== Build: Release in gtkLearning (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lgtk-4: No such file or directory|
ld.exe||cannot find -lgraphene-1.0: No such file or directory|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 4 second(s)) ===|
I tried to add libraries to the linker settings in release mode, but nothing worked for me.
Please help me fix the project.
Did you try changing linker option
to
pkg-config --libs --static gtk4
I have no idea if it will work or not.
Tim S.
I installed GTK4 with the command pacman -S mingw-w64-x86_64-gtk4.
Build log:-------------- Clean: Release in gtkLearning (compiler: GNU GCC Compiler)---------------
Cleaned "gtkLearning - Release"
-------------- Build: Release in gtkLearning (compiler: GNU GCC Compiler)---------------
gcc.exe -Wall -O2 -std=c23 -m64 -IN:\msys64\mingw64\include -IN:\msys64\mingw64\include\gtk-4.0 -IN:\msys64\mingw64\include\cairo -IN:\msys64\mingw64\include\gdk -IN:\msys64\mingw64\include\glib-2.0 -IN:\msys64\mingw64\lib\glib-2.0\include -IN:\msys64\mingw64\include\pango-1.0 -IN:\msys64\mingw64\include\atk-1.0 -IN:\msys64\mingw64\include\gdk-pixbuf-2.0 -IN:\msys64\mingw64\include\graphene-1.0 -IN:\msys64\mingw64\include\harfbuzz -IN:\msys64\mingw64\lib\graphene-1.0\include -c N:\MyProgramming\gtkLearning\main.c -o obj\Release\main.o
gcc.exe -o bin\Release\gtkLearning.exe obj\Release\main.o -LN:/msys64/mingw64/bin/../lib -lgtk-4 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -
lcairo -lvulkan-1.dll -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -s -static-libstdc++ -static-libgcc -static -m64 N:\msys64\mingw64\lib\libgtk-4.dll.a N:\msys64\mingw64\lib\libgraphene-1.0.dll.a -mwindows
N:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgtk-4: No such file or directory
N:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: have you installed the static version of the gtk-4 library ?
N:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgraphene-1.0: No such file or directory
N:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: have you installed the static version of the graphene-1.0 library ?
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
pacman -S mingw-w64-x86_64-gtk4
seems to install the gtk4 libraries for dynamic linking only. I don't see a static build for gtk4 in Msys2's packages.
So, is there a reason you did not try the linker command changes I suggested?
Edit: The GTK4 static libs do not exist that I can find.
$ pkg-config --libs --static gtk4
-lgtk-4 -lpangocairo-1.0 -lm -lgdi32 -lpangoft2-1.0 -lm -lpangowin32-1.0 -lm -lgdi32 -ldwrite -lpango-1.0 -lm -lfribidi
-lthai -ldatrie -lharfbuzz-gobject -lgdk_pixbuf-2.0 -lm -lintl -lgdiplus -lole32 -ltiff -ljbig -lz -lwebp -lsharpyuv -lz
std -llzma -lLerc -ljpeg -ldeflate -lcairo-gobject -lm -lgdi32 -lmsimg32 -ldwrite -ld2d1 -lwindowscodecs -lcairo -lm -lg
di32 -lmsimg32 -ldwrite -ld2d1 -lwindowscodecs -lfontconfig -lintl -lm -lexpat -lfreetype -lbz2 -lpng16 -lharfbuzz -lm -
lusp10 -lgdi32 -lrpcrt4 -luser32 -lgraphite2 -lbrotlidec -lbrotlicommon -lpixman-1 -lm -pthread -lvulkan-1.dll -lgraphen
e-1.0 -lm -pthread -lgio-2.0 -lintl -lshlwapi -ldnsapi -liphlpapi -lws2_32 -lgobject-2.0 -lintl -LC:/msys64/mingw64/lib/
../lib -lffi -lgmodule-2.0 -lglib-2.0 -lintl -lws2_32 -lole32 -lwinmm -lshlwapi -luuid -latomic -lm -lpcre2-8 -lz
Tim S.
N:\msys64\mingw64\lib\libgtk-4.dll.a N:\msys64\mingw64\lib\libgraphene-1.0.dll.a
Linking against DLLs and complaining it links against DLLs is not a smart thing to do.
Decide do you wish to link against these two DLLs or do you not wish to do that!
Oops, you might be right. Edit2: The shared gtk4 libs seems to be missing.
$ ls /mingw64/lib/libgraphene-1.0.a
ls: cannot access '/mingw64/lib/libgraphene-1.0.a': No such file or directory
Tim S.