Author Topic: CodeBlocks 64bit, MSys2 and GTK  (Read 3117 times)

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 29
CodeBlocks 64bit, MSys2 and GTK
« on: April 01, 2025, 11:12:36 am »
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:
Code
||=== 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #1 on: April 01, 2025, 04:35:59 pm »
Did you try changing linker option

Code
pkg-config --libs gtk4

to

Code
pkg-config --libs --static gtk4

I have no idea if it will work or not.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #2 on: April 01, 2025, 09:05:43 pm »
FYI: Posting the Build Log instead of the Build Messages might help you to get help!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #3 on: April 02, 2025, 11:49:24 am »
I installed GTK4 with the command pacman -S mingw-w64-x86_64-gtk4.
Build log:
Code
-------------- 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))

Offline Grit Clef

  • Multiple posting newcomer
  • *
  • Posts: 112
  • Where there is a will, there is a way.
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #4 on: April 02, 2025, 12:32:38 pm »
Code
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.
-Windows 7, 32-bit
-CodeBlocks r13542, gcc 14.2.0, debug version

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #5 on: April 02, 2025, 07:33:42 pm »
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.

Code
$ 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.
« Last Edit: April 02, 2025, 07:54:38 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #6 on: April 02, 2025, 07:38:57 pm »
Code
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.

Code
$ ls /mingw64/lib/libgraphene-1.0.a
ls: cannot access '/mingw64/lib/libgraphene-1.0.a': No such file or directory

Tim S.
« Last Edit: April 02, 2025, 07:45:37 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7778
    • My Best Post
Re: CodeBlocks 64bit, MSys2 and GTK
« Reply #7 on: April 02, 2025, 07:47:35 pm »
You do realize that static linking means that GCC GPL license applies to the software you are writing; so, this is normally considered bad for any  software you plan to sell.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org