Author Topic: linking GTK with codeblocks?  (Read 11496 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6800
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #15 on: January 06, 2016, 07:43:07 pm »
The MSys2 GTK3 Packages I added; I added all of gtk3 recommend packages.
Code: [Select]
pacman -S mingw-w64-x86_64-gtk3             # It takes the installer a lot of time to search the fonts folder; just wait.
pacman -S mingw-w64-x86_64-gdk-pixbuf2

Patch file of the changes I needed to do to CB GTK Wizard; to make it work with GTK3 and Code::Blocks 13.12.

Tim S.


Code: [Select]
gtk/wizard.script | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gtk/wizard.script b/gtk/wizard.script
index 2843dfd..82cc326 100644
--- a/gtk/wizard.script
+++ b/gtk/wizard.script
@@ -54,14 +54,14 @@ function OnLeave_GtkPath(fwd)
         local dir_nomacro_inc = GetCompilerIncludeDir(dir, GtkPathDefault, GtkPathDefaultInc);
         if (dir_nomacro_inc.IsEmpty())
             return false;
-        if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtk-2.0") + wxFILE_SEP_PATH +_T("gtk"), _T("gtk.h"), _T("GTK's include")))
+        if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtk-3.0") + wxFILE_SEP_PATH +_T("gtk"), _T("gtk.h"), _T("GTK's include")))
             return false;
 
         // verify library dependencies
         local dir_nomacro_lib = GetCompilerLibDir(dir, GtkPathDefault, GtkPathDefaultLib);
         if (dir_nomacro_lib.IsEmpty())
             return false;
-        if (!VerifyLibFile(dir_nomacro_lib, _T("gtk-win32-2.0"), _T("GTK's")))
+        if (!VerifyLibFile(dir_nomacro_lib, _T("gtk-3.dll"), _T("GTK's")))
             return false;
 
 
@@ -113,14 +113,14 @@ function SetupProject(project)
     if (PLATFORM == PLATFORM_MSW)
     {
         project.AddIncludeDir(GtkPathDefaultInc);
-        project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gtk-2.0"));
+        project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gtk-3.0"));
         project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("cairo"));
         project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk"));
         project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("glib-2.0"));
         // Notice GtkPathDefault*Lib* at some positions. This is correct as of 2.8.20
         project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("glib-2.0") + wxFILE_SEP_PATH + _T("include"));
         project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("pango-1.0"));
-        project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("gtk-2.0")  + wxFILE_SEP_PATH + _T("include"));
+        project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("gtk-3.0")  + wxFILE_SEP_PATH + _T("include"));
         project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("atk-1.0"));
         if ( IO.DirectoryExists(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-2.0")) )
             project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-2.0"));
@@ -128,7 +128,7 @@ function SetupProject(project)
         project.AddLibDir(GtkPathDefaultLib);
 
         // add link libraries
-        project.AddLinkLib(_T("gtk-win32-2.0"));
+        project.AddLinkLib(_T("gtk-3"));
         project.AddLinkLib(_T("gobject-2.0"));
         project.AddLinkLib(_T("glib-2.0"));
 
« Last Edit: January 06, 2016, 08:34:49 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6800
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #16 on: January 06, 2016, 07:52:47 pm »
Before running the CB GTK Wizard you need to setup the GCC Compiler as using MSys2 mingw64 gcc compiler and set it as the default compiler. If you need help on this step ask.

If you do NOT know how to edit the CB Wizards try right clicking on the GTK Wizard Icon.
Remember to save the changes.

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

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #17 on: January 07, 2016, 04:13:11 am »
Thank you that worked out quite well. I had to make a few further changes, but it was nothing I couldn't figure out. I appreciate the help very much. I changed the gtk-win32-2.0 references to 3.0 references. I have tried deleting and reinstalling msys2 about 3 times, and each time I try to install GTK, it still doesn't download the complete file set, but I managed to find a different GTK3 download (not through msys2) that I still dont believe is complete, but it apparently has some of the missing files. The hello world sample still won't compile, but I believe that is just a problem of missing libraries that I'll have to try to find.

You, my friend, are a life saver.

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #18 on: January 07, 2016, 05:43:19 am »
well, it seems that I'm getting alot of strange behavior. I can build the sample program once, and it comes back with virtually everything listed as "undefined references". stop code blocks and run it again, with no changes to the code, and it compiles fine. try to run it a second time (again with no changes) and the build and run options are grayed out. I may try to fix it over the next couple of hours and if that doesn't work, It looks like i'll be using QT.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12348
    • Travis build status
Re: linking GTK with codeblocks?
« Reply #19 on: January 07, 2016, 08:19:22 am »
Can you record a video of this behaviour?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9592
Re: linking GTK with codeblocks?
« Reply #20 on: January 07, 2016, 11:01:08 am »
The MSys2 GTK3 Packages I added; I added all of gtk3 recommend packages.
Patch file of the changes I needed to do to CB GTK Wizard; to make it work with GTK3 and Code::Blocks 13.12.
That can only be an interim-patch. Better would be to support both version by lettings the user choose.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6800
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #21 on: January 07, 2016, 03:01:42 pm »
The MSys2 GTK3 Packages I added; I added all of gtk3 recommend packages.
Patch file of the changes I needed to do to CB GTK Wizard; to make it work with GTK3 and Code::Blocks 13.12.
That can only be an interim-patch. Better would be to support both version by lettings the user choose.

I agree; but, the OP needed it before I will have time to add the GUI choice. I am still not very good at the Scripting code changes esp. when it requires GUI stuff. But, it sounds like the OP has stopped using MSys2; so, I will likely give up helping because I decided that getting MSys2 and Code::Blocks working is what I am trying to get done right now. Will post a patch as I think is needed for GTK2/3 and MSys2 compiler in the future. After that, I plan to work on SDL1/2 CB Wizard and MSys2 patch.

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

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #22 on: January 08, 2016, 09:36:51 pm »
Can you record a video of this behaviour?

I can probably get some screenshots, but that's about the best I can do. I don't have any sort of video capture software on my laptop.

edit: I went in to try to get the screenshots, and the behavior isn't replicating today.
As it stands, I can get a blank window to open from the tutorial code from the gtk website: http://www.gtk.org/tutorial1.2/gtk_tut-2.html
(I posted the link to the location where I got the code rather than post the code itself to save space. I copy/pasted the code verbatim fro that tutorial



When working on the hello world sample on the same page, I get 17 errors and 4 warnings:


Code: [Select]
||=== Build: Debug in newgtk (compiler: GNU GCC Compiler) ===|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c||In function 'main':|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|57|warning: implicit declaration of function 'gtk_signal_connect' [-Wimplicit-function-declaration]|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|57|warning: implicit declaration of function 'GTK_OBJECT' [-Wimplicit-function-declaration]|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|58|warning: implicit declaration of function 'GTK_SIGNAL_FUNC' [-Wimplicit-function-declaration]|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|81|warning: implicit declaration of function 'gtk_signal_connect_object' [-Wimplicit-function-declaration]|
obj\Debug\main.o||In function `hello':|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|10|undefined reference to `g_print'|
obj\Debug\main.o||In function `delete_event':|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|23|undefined reference to `g_print'|
obj\Debug\main.o||In function `main':|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|57|undefined reference to `GTK_SIGNAL_FUNC'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|57|undefined reference to `GTK_OBJECT'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|57|undefined reference to `gtk_signal_connect'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|63|undefined reference to `GTK_SIGNAL_FUNC'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|63|undefined reference to `GTK_OBJECT'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|63|undefined reference to `gtk_signal_connect'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|67|undefined reference to `g_type_check_instance_cast'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|75|undefined reference to `GTK_SIGNAL_FUNC'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|75|undefined reference to `GTK_OBJECT'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|75|undefined reference to `gtk_signal_connect'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|81|undefined reference to `GTK_OBJECT'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|81|undefined reference to `GTK_SIGNAL_FUNC'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|81|undefined reference to `GTK_OBJECT'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|81|undefined reference to `gtk_signal_connect_object'|
C:\Users\Will\Documents\learning\C++\misc\newgtk\main.c|86|undefined reference to `g_type_check_instance_cast'|
||=== Build failed: 17 error(s), 4 warning(s) (0 minute(s), 1 second(s)) ===|


While I'm not exactly an expert with GTK+, I do know that the g_print() function is a part of the Glib library (Glib is a dependency of GTK). I added an include for glib.h, and it still came up the same .
« Last Edit: January 08, 2016, 10:31:36 pm by southernsontn »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6800
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #23 on: January 09, 2016, 02:01:20 am »
If you wish to use GTK3 then find a better sample code.

You can NOT expect several year old code to work with GTK3; it did work for me with GTK2 and MSys2.

Edit: I am guessing the "tutorial1.2" means it was written for GTK1.2.
Edit2: Learn how to create a full rebuild log; this will be needed when you seek help on a site that supports GTK3.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Edit3: Link to some directions I am working on for GTK3 and MSys2
https://github.com/stahta01/cb_misc/blob/master/Notes/MSys2/Setting%20up%20MSys2%20for%20using%20GTK3%20with%20external%20CodeBlocks%20IDE.txt

Tim S.
 
« Last Edit: January 09, 2016, 02:44:27 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6800
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #24 on: January 10, 2016, 01:01:37 am »
Patch that I plan to test more in the future; but, I plan to change more CB Wizards before doing that testing.

Tim S.

Deleted patch; Will post patches in a new thread when I finish testing them.

« Last Edit: January 16, 2016, 06:31:42 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #25 on: January 13, 2016, 09:57:22 pm »
Just as an update, I finally got GTK 3 working in my code blocks installation.

In order to do so, I edited my wizard script as Stahta posted earlier, but I never could get it working correctly with the Msys2 GTK3 bundle. fortunately, I found a source online that had the GTK library bundled by itself. Once I got everything set up with this install, everything functioned like clockwork. Thanks everyone for the help, and thank you Stahta, especially.