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

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
linking GTK with codeblocks?
« on: January 04, 2016, 07:00:18 pm »
I am just learning c++, and up till now, the only code I have written has been console applications. I figured I would play around with the GTK project wizard to get a feel for it, but I can't figure out how to link codeblocks to the gtk library.

Following the instructions on the GTK download page, I installed msys2. I have no idea how to compile a pkgbuild, or what files are necessary, so I used pacman -S to download the GTK unico engine, but that didn't work, so I have started downloading every package they have under pacman -Ss gtk3.

The gtk.h file is located in "C:\msys64\mingw64\include\gtk-3.0\gtk"

Codeblocks says that it can't find an include file, which is correct, because there isn't one. I try to point the project wizard to "C:\msys64\mingw64", which is the parent directory of the include file, but then it says that it can't locate gtk.h

I apologize in advance if this is due to some failure to download the right package, but any help would be greatly appreciated.

I am running:
Windows Vista 64 bit
Codeblocks 13.12
MSYS2
and the GTK version that MSYS is trying to download is apparently GTK 3.0

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #1 on: January 04, 2016, 07:53:30 pm »
Post the link to the directions you are following.

Note: Your question will likely drift off topic for this site.
I edit this post or pm you a link to another site if that happens.

Are you using Windows 32 bit or Windows 64 bit? Windows Vista 64 bit

Edit2: I will be using Code::Blocks 15.12RC1 on Windows 7 (either 32 bit or 64 bit)

Tim S.

I am just learning c++, and up till now, the only code I have written has been console applications. I figured I would play around with the GTK project wizard to get a feel for it, but I can't figure out how to link codeblocks to the gtk library.

Following the instructions on the GTK download page, I installed msys2. I have no idea how to compile a pkgbuild, or what files are necessary, so I used pacman -S to download the GTK unico engine, but that didn't work, so I have started downloading every package they have under pacman -Ss gtk3.

The gtk.h file is located in "C:\msys64\mingw64\include\gtk-3.0\gtk"

Codeblocks says that it can't find an include file, which is correct, because there isn't one. I try to point the project wizard to "C:\msys64\mingw64", which is the parent directory of the include file, but then it says that it can't locate gtk.h

I apologize in advance if this is due to some failure to download the right package, but any help would be greatly appreciated.

I am running:
Windows Vista 64 bit
Codeblocks 13.12
MSYS2
and the GTK version that MSYS is trying to download is apparently GTK 3.0
« Last Edit: January 04, 2016, 07:55:58 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 #2 on: January 04, 2016, 11:39:09 pm »
Well, the GTK windows download site gives this link for instructions on installing GTK, but those directions are are focused on programming with Gedit, apparently. I want to install gtk for use with codeblocks.

https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtk-application-on-windows/

The blog website also give some directions for compiling GTK for use with visual C++, but I'm honestly not sure how relevant to code blocks those directions will be.

https://wiki.gnome.org/action/show/Projects/GTK+/Win32/MSVCCompilationOfGTKStack#The_Dependencies

At this point, I really don't want to go around pointlessly downloading things that I really don't need, since I've already downloaded god only knows how much trying to get this running. I know that at some point I will try to use a program I built on another computer and I would hate to have to download 7 or 8 GB of content just to run a 100 mb program...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #3 on: January 05, 2016, 12:39:33 am »
Are you planning on using gtk2 or gtk3?

If it makes no difference I will use gtk2.

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 #4 on: January 05, 2016, 12:54:22 am »
well, I am planning to use GTK3, but when installing everything with msys2, apparently it installed both GTK3 and GTK2. As this point, I have no preference as long as I get something running correctly.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #5 on: January 05, 2016, 12:58:05 am »
I will do gtk2 under Windows 7 32 bit; this might take a few days to figure it out or just a few hours.

Then, I will start on GTK3 on Windows 7 64 bit.

If you did NOT know MSys2 32bit and 64 bit are different from each other.
(64 bit is easier in most ways)

Edit: I have no knowledge of either version of GTK.
I plan on just getting the Code::Blocks wizard sample code working with GTK2/3 using the MSys2 compiler.
Edit3: The Code::Blocks Wizard is hard coded to use GTK2; that is why I am doing GTK2 first.

Edit2: I am trying to get the MSys2 compiler to work better with Code::Blocks.

Tim S.
« Last Edit: January 05, 2016, 01:19:54 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 southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #6 on: January 05, 2016, 01:15:18 am »
I try to run the 64 bit versions of software for compatibility issues, but I forget to mention that I'm using that version from time to time. Honestly, aside from memory allocation abilities, I'm not entirely educated about the difference. I am autodidactic in regards to computers, and from time to time I tend to overlook certain things only to find that I have to go back and learn them later when I should have learned them in the first place.

without steering too far off topic, From a programming standpoint, is there a major difference writing programs for 32 vs. 64 bit that I should be aware of?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #7 on: January 05, 2016, 01:23:56 am »
When using 32 bit DLLs in MSys2 you get a weird run-time error that requires to run a batch file to redo the base addressing for all of the DLLs. That is the major newbie issue that I stumbled over a few months, ago. This includes MSYS2 built DLLs. I had to run the batch file every month or so.

Tim S.

I try to run the 64 bit versions of software for compatibility issues, but I forget to mention that I'm using that version from time to time. Honestly, aside from memory allocation abilities, I'm not entirely educated about the difference. I am autodidactic in regards to computers, and from time to time I tend to overlook certain things only to find that I have to go back and learn them later when I should have learned them in the first place.

without steering too far off topic, From a programming standpoint, is there a major difference writing programs for 32 vs. 64 bit that I should be aware of?
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: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #8 on: January 05, 2016, 01:33:10 am »
I Have gotten an edited Code::Blocks SVN 10638 to build GTK2 sample.

Now, I need to switch to my Windows 7 64 bit laptop and see if that works.

If you are a Git User; I am using this branch to do my work.
https://github.com/stahta01/codeblocks_https_metadata/tree/msys2_gtk

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 #9 on: January 05, 2016, 01:56:15 am »
When using 32 bit DLLs

Ok, so it's something that I'll have to look at down the road. I'm far from building applications that require the use of DLLs (I have only wrote a few very minor console applications, and those have just been modestly upgraded versions of the examples found in the C++ books I've read.

Since I'm not actually getting any formal education in the subject, and I don't personally know anyone in computer programming, I am basically learning from a few books (mostly older, prior to C++0x), let alone the newest standard), online tutorials, and browsing message boards for what information I can gather. I don't really post on them much because my questions can sometimes tend to get a little... abstract, and from what I've noticed programming message boards (understandably) aren't geared towards catering to the ultra new user. Therefore, I typically read a little bit on a particular topic, cross reference it with what the other books say about the topic, and then spend some time further researching it through online tutorials, blogs, online forums, etc. just so I can further understand it. I don't want to learn "You type this in, and the program will do this", I want to learn the how, why, and to what extent can this be optimized of the subject. Follow up questions of that nature tend to be seen as either off topic, wasting time, or trolling...

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #10 on: January 05, 2016, 02:04:51 am »
If you are a Git User

not at the moment, but I should probably check it out

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6667
    • My Best Post
Re: linking GTK with codeblocks?
« Reply #11 on: January 05, 2016, 02:58:25 am »
I gave up on Fixing the CB Wizard for GTK3; I just do NOT have the time right now.

I am attaching an User Template for building GTK3 CB Projects using MSys2 MinGW 64 bit GCC.
It uses the Code::Blocks GCC compiler alias.

You can put User Templates into "%APPDATA%\CodeBlocks\UserTemplates"
In my case it is "C:\Users\stahta01\AppData\Roaming\CodeBlocks\UserTemplates"
Edit: I would just save the zipped file; and see if it works after unzipping and if it does do a save as template operation in CB.

Tim S.

Deleted attachment.


« Last Edit: January 16, 2016, 06:30:23 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 #12 on: January 05, 2016, 05:17:44 am »
I understand completely. Thanks for the time invested. I'll try your workaround and see if I can get something going.

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #13 on: January 06, 2016, 09:50:49 am »
I tried the template that you attached, and while it loaded, nothing would compile... it got stuck at the gtk header file. I tried a few things, but nothing worked.

with that being said, I'm going to start back over from scratch and try a few things. If I can get everything working, I'll come back and post my solution.

Offline southernsontn

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: linking GTK with codeblocks?
« Reply #14 on: January 06, 2016, 12:07:20 pm »
well, if you're still interested: I see now what the problem is. The files installed through Msys2 are, for some reason, incomplete. same thing goes for GTK2 through Msys2. I have actually managed to track down some of the necessary files (mostly .dlls) through various means, and I can now start a GTK+ project with GTK2. The Hello world sample won't compile though, it's still missing a few things. Once I get a working, compiling program with GTK2, I'll go back and try to rebuild a complete GTK3 library.

I am learning far more about code blocks than I ever intended to, but I suppose that's a good thing.