GTK4 Setup On Windows in VScode with/without CMake (easy) - C/C++

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024

Комментарии • 55

  • @cosecseccot
    @cosecseccot  Год назад +6

    Sample Code:
    #include
    static void print_hello(GtkWidget *widget, gpointer data) { g_print("Hello World
    "); }
    static void activate(GtkApplication *app, gpointer user_data) {
    GtkWidget *window;
    GtkWidget *label = gtk_label_new (NULL);
    window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "GTK-4.0 Test Window");
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
    gtk_label_set_markup (GTK_LABEL (label), "Hello World");
    gtk_label_set_xalign(GTK_LABEL (label), 0.5f);
    gtk_label_set_yalign(GTK_LABEL (label), 0.5f);
    gtk_window_set_child(GTK_WINDOW(window), label);
    gtk_window_present(GTK_WINDOW(window));
    }
    int main(int argc, char **argv) {
    GtkApplication *app;
    int status;
    app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
    g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
    status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
    return status;
    }

  • @brandonsamuelcruzsilva7626
    @brandonsamuelcruzsilva7626 8 месяцев назад +1

    I spent one week trying to find a solution like this one, THANK YOU!

  • @VerzatileDev
    @VerzatileDev Год назад +1

    you for sure deserve the follow, like and all the rest, can't belive how much hurdle one library needs (I mean a collection of libraries).

  • @MarcosSantos-cp5yr
    @MarcosSantos-cp5yr 4 месяца назад +1

    ty! I really need this for a job, hugs from Brazil =)

  • @Rubin-Igor
    @Rubin-Igor 8 месяцев назад +2

    wszystko prosto i po kolei 😘😘

  • @raven_lee_black
    @raven_lee_black 4 дня назад

    I see some tutorials use the yellow one on msys. I was curious if it matters, as far as, when you go to use pac man for gtk in the yellow term versus the blue term? I would think it would.

  • @NeilHaran
    @NeilHaran 14 дней назад +2

    In your video, do we need to copy GTK include directories into msys64?
    edit: nevermind, I missed a ming step. It works now. Thanks.

    • @cosecseccot
      @cosecseccot  14 дней назад +1

      I think I did that in my previous video (which did not had voice over), I dont remember it that clearly tbh, I think I need to remake this tutorial now lol

    • @NeilHaran
      @NeilHaran 14 дней назад

      @@cosecseccot no worries actually, I think in one of the steps I goofed up and missed a crucial ming64 install. I think it works now. Thanks for the video, it is very good.

  • @ParuhWaktuChannel
    @ParuhWaktuChannel Год назад +1

    thank you very much
    you saved my life

  • @bennguyen1313
    @bennguyen1313 7 месяцев назад +2

    Around the 18m mark, you copy just the application and yet VS Code knows the compiler / target to build it? Did you setup a makefile off-camera?
    I'd like to use the Free Visual Studio Community.. any thoughts on getting GTK4 on windows using gvsbuild to generate the gtk-build projects (ninja, meson, cmake, gtk4). According to the readme, it says it still needs MSYS2 (but not sure why), it seems to it only needs to do:
    pip install gvsbuild
    gvsbuild build gtk4

    • @cosecseccot
      @cosecseccot  7 месяцев назад

      1. its because of the cmakelists.txt file, and i build the project before copying the code, as it says 'gtk4 found'. 16:52
      2. i think thats becuase gtk4 is in msys2's include directories, if you check out the cmakelists.txt code, every include file and libraries are in 'mysys64/mingw64/' directory
      (i actually dont know what gvsbuild and the other stuff is, i can make a video about that after some research)

    • @bennguyen1313
      @bennguyen1313 7 месяцев назад

      @@cosecseccotThanks! A video would be great on how to setup Visual Studio Community to include/link to the correct GTK files, setup compiler/makefiles, etc. For example, even installing GTK via:
      vcpkg install gtk:x64-windows and vcpkg integrate install
      requires one to write a vcpkg.jsonn file!

    • @cosecseccot
      @cosecseccot  7 месяцев назад

      @@bennguyen1313 ahh, I actually tried installing gtk through vcpkg but I couldn't most probably because I didn't knew you had to make a vcpkg.json
      Thank you for subscribing, will be making a new video soon

  • @aloyspranesh3727
    @aloyspranesh3727 День назад

    Bro I moved mingw path up in environmental variables still while running exe file i am having the error. What to do?

  • @techJayant15
    @techJayant15 9 месяцев назад +1

    Sir i am geeting an error while compilng c file which includes gtk.h file
    How to share image of it to you

    • @cosecseccot
      @cosecseccot  9 месяцев назад

      just tell me the error
      most probably you got the include directories wrong, so cross check to see if they are there

  • @vaishnaviwalia5055
    @vaishnaviwalia5055 7 месяцев назад +1

    Hey I am getting the error at around 16:48 mins, Bad CMake executable: "". Check to make sure it is installed or the value of the "cmake.cmakePath" setting contains the correct path. I tried re-installing the extensions, but its still there. Could you please help?

    • @cosecseccot
      @cosecseccot  7 месяцев назад

      Maybe you forgot to put the cmake executable to path, try runing make on your terminal to check it's on system PATH
      if it's working fine
      Try moving it up, like what I did in the error resolving part
      As u can see in 22:14 I have C:\CMake\bin in the path with other things
      Try to move these up

    • @kapichy97
      @kapichy97 7 месяцев назад

      I'm having the same problem, but already have cmake installed, system Path has been configured, even I set the cmakepath on that folder (for me "C:\\Program Files\Cmake\bin") and just keep failing@@cosecseccot

    • @cosecseccot
      @cosecseccot  7 месяцев назад

      @@kapichy97 maybe you also need to install make, use choco to install it

  • @PrajwalSm-m3o
    @PrajwalSm-m3o 11 месяцев назад +1

    At 16:48 of the vdo, i am getting the error as
    bad cmake executable:"".check to make sure it is installed or the value of the "cmake.cmakepath" setting contains the correct path
    I read some other person comment too you suggested him to add path but i am not getting it, Can you help me with this please.

    • @cosecseccot
      @cosecseccot  11 месяцев назад

      1. Try reinstalling c++ extensions
      2. Try reinstalling cmake
      3. Try adding this line in your project settings folder
      "cmake.cmakePath": "path\\to\\cmake"
      (Replace it with your path to cmake)
      Try each step to check if it resolves your issue

    • @vaishnaviwalia5055
      @vaishnaviwalia5055 7 месяцев назад

      Hey I am getting the same issue, did you resolve it?

  • @night-bi1gq
    @night-bi1gq 11 месяцев назад +1

    @cosecseccot your the best man you helped me a lot with this tutorial thx for everything.

  • @siddhartht8063
    @siddhartht8063 Год назад +1

    can u pls help me with this cmake error. Once I clicked command pallet --> cmake configure --> I get this error --> "Bad CMake executable: "cmake.camkepath". Check to make sure it is installed or the value of the "cmake.cmakePath" setting contains the correct path". I tried many ways but caunt figur it out

    • @cosecseccot
      @cosecseccot  Год назад

      You probably haven't installed cmake, and if you have you need to add it to "PATH"
      That might fix the issue

  • @monis_10
    @monis_10 8 месяцев назад +1

    Hi, it says "[rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Build failed: Unable to configure the project {}" i tried to do it using cmake and try to include the directories in the include path line using intellisense but still doesnt work for me. The thing is I accidentally changed my user variable path too, so I dont know if that's the issue, my system variable path is unaffected but i accidentally replaced the user variable, so i dont know if this is the reason that its not working, and if i want to try restoring the user variable path, do you know how can it be done?

    • @cosecseccot
      @cosecseccot  8 месяцев назад +1

      I think you should try chatgpt, since ur problem is very specific, I will try to recreate your problem in the meantime and get back at u

    • @monis_10
      @monis_10 8 месяцев назад

      thank you so much for your cooperation ur da best@@cosecseccot

  • @victoragahi5915
    @victoragahi5915 Год назад +1

    hey bro that doesn't work for me, I want to download GTK3 on my Windows PC and your tutorial didn't help me, do you have advice pr GTK3 ?

    • @cosecseccot
      @cosecseccot  Год назад

      I'm sorry bro, I haven't tried gtk3, but ... all I can say is thoroughly follow instructions on their website

    • @cosecseccot
      @cosecseccot  Год назад

      Like see some cmake tutorials, it's not too hard, you will get it, and utilize it for gtk3

    • @victoragahi5915
      @victoragahi5915 Год назад

      @@cosecseccot yeah I spend 4 hours to watch tutorial and nothing change

    • @cosecseccot
      @cosecseccot  Год назад

      @@victoragahi5915 try chatgpt ? Ask it to "how to setup gtk3 on windows in vscode using cmake"
      If you get any errors in the code it writes, tell gpt the errors and work on it, if they are un resolved try to understand the errors from stack overflow or chatgpt itself and work your way through

  • @rofy9969
    @rofy9969 7 дней назад

    11:00 the bin folder its empty, what i have to do?

    • @cosecseccot
      @cosecseccot  7 дней назад

      @@rofy9969 try reinstalling it

  • @jjgameentertainments7811
    @jjgameentertainments7811 Год назад +1

    Brother, This is very useful 😊
    But When i do some modifications .
    For eg, First I run As Hello world, then i clicked run task and the output is correct..
    Then i changed the value as "welcome" and clicked run task, but it shows hello world again why ?

  • @mehanth7304
    @mehanth7304 5 месяцев назад +1

    thank u so much i literally cried after setting this up🥲

    • @cosecseccot
      @cosecseccot  5 месяцев назад +1

      np man, im glad it could help

  • @nurca7903
    @nurca7903 5 месяцев назад +1

    how do i revert back and remove everything gtk

    • @cosecseccot
      @cosecseccot  5 месяцев назад

      make a new project or start wih a new folder ? i dont know what do you mean exactly

  • @cyborgzone7143
    @cyborgzone7143 Год назад +1

    bro cmake error

  • @andriamilaminamanohiarivel6083
    @andriamilaminamanohiarivel6083 Год назад +1

    i don't know why but i get these error when i try to build the code ;
    [build] Starting build
    [proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" --build "c:/Users/dell/Documents/GTK tutorial/build" --config Debug --target all -j 6 --
    [build] [ 50%] Building C object CMakeFiles/TutorialApp.dir/main.c.obj
    [build] gcc.exe: fatal error: cannot specify '-o' with '-c', '-S' or '-E' with multiple files
    [build] compilation terminated.
    [build] mingw32-make[2]: *** [CMakeFiles\TutorialApp.dir\build.make:76: CMakeFiles/TutorialApp.dir/main.c.obj] Error 1
    [build] mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/TutorialApp.dir/all] Error 2
    [build] mingw32-make: *** [Makefile:90: all] Error 2
    [proc] The command: "C:\Program Files\CMake\bin\cmake.exe" --build "c:/Users/dell/Documents/GTK tutorial/build" --config Debug --target all -j 6 -- exited with code: 2
    [driver] Build completed: 00:00:00.473
    [build] Build finished with exit code 2
    can you help me ?

    • @andriamilaminamanohiarivel6083
      @andriamilaminamanohiarivel6083 Год назад +1

      nevermind i 've figured it out ,thank you such a good video

    • @cosecseccot
      @cosecseccot  Год назад

      @@andriamilaminamanohiarivel6083 sorry i didnt saw ur comment earlier, im glad it worked for you :)
      Try using chatgpt, its really helpful for these kinds of errors, i use it all the time

  • @fouadbkh5453
    @fouadbkh5453 9 месяцев назад +1

    i didn't use cmake and i followed all the steps i also stup all that files
    fatal error: gtk/gtk.h: No such file or directory
    #include
    ^

    • @cosecseccot
      @cosecseccot  9 месяцев назад

      I recommend you to use cmake since this tutorial has gotten pretty old and the usual way might not work

    • @cosecseccot
      @cosecseccot  9 месяцев назад

      You can try checking the include directories in vscode tho

  • @9809090980
    @9809090980 3 месяца назад

    I need your email for technical support I am getting errors with and without cmake could you please help me?