sohamkorade / chess_engine

A basic chess engine made in pure C++.
0 stars 1 forks source link

compilation failed : G_APPLICATION_DEFAULT_FLAGS not declared #10

Open tissatussa opened 1 month ago

tissatussa commented 1 month ago

that variable is at the end of the Makefile : it's not declared and i get an error :

$ make
g++ -Wall -Ofast -c main.cpp
g++ -Wall -Ofast -c board.cpp
g++ -Wall -Ofast -c movegen.cpp
g++ -Wall -Ofast -c search.cpp
g++ -Wall -Ofast -o main main.o board.o movegen.o search.o
g++ -Wall -Ofast -c runtest.cpp -o runtest.o 
g++ -Wall -Ofast -o runtest runtest.o board.o movegen.o search.o
g++ -Wall -Ofast -c gui.cpp `pkg-config --cflags --libs gtk4`
gui.cpp: In function ‘int main(int, char**)’:
gui.cpp:481:46: error: ‘G_APPLICATION_DEFAULT_FLAGS’ was not declared in this scope; did you mean ‘G_APPLICATION_GET_CLASS’?
  481 |       gtk_application_new("org.soham.chess", G_APPLICATION_DEFAULT_FLAGS);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                              G_APPLICATION_GET_CLASS
make: *** [Makefile:47: gui.o] Error 1

i hope you can solve this, i'm curious how your engine plays .. btw. what's the name of the engine ? "Yonder" ?

greetings from Holland !

[ i'm on Xubuntu 22.04 ]

sohamkorade commented 1 month ago

Hi Roelof, thanks for reaching out!

I suppose you have an older GTK4 release. Try updating with sudo apt install libgtk-4-dev. If that doesn't work, please provide the output for pkg-config --cflags --libs gtk4.

You can still try out the UCI-compatible engine binary (make main).

tissatussa commented 1 month ago

libgtk-4-dev seems to be installed on my OS .. here's the output you suggested :

$ pkg-config --cflags --libs gtk4
-mfpmath=sse -msse -msse2 -pthread -I/usr/include/gtk-4.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

can this info help you to solve my issue ?

sohamkorade commented 1 month ago

I am not exactly sure if it helps. Here is my output for comparison:

$ pkg-config --cflags --libs gtk4
-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lvulkan -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

Can you try compiling after replacing G_APPLICATION_DEFAULT_FLAGS with G_APPLICATION_FLAGS_NONE?

Refer: https://www.reddit.com/r/GTK/comments/105kri7/proper_way_to_deal_with_deprecated_g_application/

tissatussa commented 1 month ago

that works ! i'm playing a game now in the gui, which looks nice ! however, first i had to create a folder archive in root ?!

that refer is awesome : how to deal with those deprecated variables on all OS - didn't know that, never used it.

the main UCI binary runs fine in CuteChess, it just won its first game 10m5s !

[Event "engine vs engine"]
[Site "Holland"]
[Date "2024.07.12"]
[Round "?"]
[White "Yonder"]
[Black "YoBot Bronze"]
[Result "1-0"]
[ECO "B00"]
[GameDuration "00:03:52"]
[Opening "King's pawn Opening"]
[PlyCount "45"]
[TimeControl "600+5"]

1. e4 {0.00/5 12s} d6 2. Bb5+ {+0.60/4 11s} c6 3. Bd3 {+0.25/5 10s} f6
4. Nc3 {+1.10/4 13s} e6 5. Qh5+ {+1.10/4 18s} g6 6. Qd1 {+1.08/4 13s} Qc7
7. Nf3 {+1.20/4 11s} Bg7 8. O-O {+1.25/4 11s} Qa5 9. Bc4 {+1.40/3 12s} c5
10. d4 {+1.68/3 14s} cxd4 11. Nxd4 {+1.90/3 12s} f5 12. exf5 {+2.00/1 11s} gxf5
13. Re1 {+1.81/2 12s} Bxd4 14. Qxd4 {+2.36/3 11s} Nf6 15. Qxf6 {+4.07/3 12s} Rg8
16. Bxe6 {+6.08/3 11s} Bxe6 17. Qxe6+ {+8.02/4 12s} Kd8 18. Qxg8+ {+8.19/4 6.8s}
Kc7 19. Re7+ {+8.45/3 12s} Kb6 20. Qb3+ {+M7/4 5.3s} Kc6 21. Qxb7+ {+M5/3 0.78s}
Kc5 22. Be3+ {+M3/2 0.11s} Kc4 23. Qb3# {+M1/1 0.079s, White mates} 1-0
tissatussa commented 1 month ago

here's the first GUI game, i could not win ..

arrowgram-RB-vs-Yonder

[ ani diagram made with apronus.com ]

[Event "human vs engine"]
[Site "Holland"]
[Date "2024.07.12"]
[Round "?"]
[White "Roelof Berkepeis"]
[Black "Yonder"]
[Result "0-1"]
1. e4 d5 2. exd5 Qxd5 3. Nc3 Qd7 4. Bb5 Nc6 5. d4 a6 6. Bxc6 Qxc6 7. Qf3+ Qg6 8. Qxe4+ Qxe4+ 9. Nxe4 Bf5+ 10. f3+ Nf6+ 11. Nxf6 exf6+ 12. cxc3+ Bd6+ 13. Ne2+ Kxe7+ 14. Be3+ Rhxd8+ 15. O-O-O+ Bxd7+ 16. d5+ c6+ 17. Nf4+ g5+ 18. Nh5+ cxd5+ 19. Rhe1+ Be6+ 20. g3+ Be5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8+ 26. Rxd1+ g5+ 27. cxc4+ h6+ 28. g3+ h5+ 29. f4+ exf4+ 30. gxf4+ gxf4+ 31. Kxf4+ Rg8+ 32. Rxd2+ Rd8+ 33. h4+ Rg8+ 34. Rxd3+ Rxg4 35. Kf3+ Rxh4+ 36. Rxd2+ Rh3 37. Kg2+ Rh4 38. Rxe2+ Rf4+ 39. Kxg3+ Rf1+ 40. Bxd4 h4+ 41. Kxh4 Rc1+ 42. c5 Rc4+ 43. Rd2# Rxd4+ 44. Rxd4+ Kxe5+ 45. Rxc4 Kf4 46. Kh5 a5 47. a3 axb4 48. axb4 a6 49. Kh6 Ke5 50. Kxg5 c6 51. Kxg4 f6 52. Kf3 f5 53. exf5 Kxf5 54. Kxe3+ Kf6 55. Rxe4+ Kf7 56. Kd4 Kf6 57. Rxe5 Kf7 58. Ke4 Kf6+ 59. Kf4 Kf7 60. Kf5 Kg7 61. Re6 Kf7+ 62. Rxc6 Ke8 63. Kxe6 Kd8 64. Rxa6 Kc8 65. cxc6 Kd8 66. Ra7 Kc8 67. b5 Kb8+ 68. b6 Kc8 69. Ra8# 1-0

in both games i gave the AI 5 seconds.

tissatussa commented 1 month ago

one of my recent games with Black, 5 seconds per move.

https://github.com/user-attachments/assets/3147bc5e-653c-4ceb-aa2a-15f88e72199f

[ i put this video on BitChute, see the description ]