Author Topic: GTK in Code:Blocks (Windows 10)  (Read 10078 times)

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
GTK in Code:Blocks (Windows 10)
« on: October 22, 2020, 11:07:07 am »
Hi there,

After a serious Windows 10 crash, I had to re-format my disk and to re-install everything on my computer, but I remain unable to re-install GTK on Code:Blocks.

The version of Code:Blocks is the last one available (20.03) but I want to install the 2.24 version of GTK.

GTK is apparently correctly installed (after pkg-config; and gtk-demo works fine). I've correctly declared (I think) in Code:Blocks directories and libraries. However, I remain unable to compile my codes, and get the following error messages:

Quote
ld.exe||cannot find -lgtk-win32-2.0| ld.exe||cannot find-lgobject-2.0| ld.exe||cannot find -lglib-2.0|

These libraries are in gtk/lib, which is declared in Code:Blocks.

This is now driving me crazy.. Especially since I've done that several times before without problems..

Thanks for any help on that & cheers,

Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #1 on: October 22, 2020, 11:12:59 am »

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #2 on: October 22, 2020, 11:53:44 am »
Thanks for your reply.

Here it is:

Code
-------------- Clean: Debug in test (compiler: GNU GCC Compiler)---------------

Cleaned "test - Debug"

-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------

gcc.exe -Wall -mms-bitfields -g -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\gtk-2.0 -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\cairo -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\gdk -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\glib-2.0 -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\lib\glib-2.0\include -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\pango-1.0 -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\lib\gtk-2.0\include -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\atk-1.0 -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk"\include\gdk-pixbuf-2.0 -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\gtk-2.0" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\cairo" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\glib-2.0" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0\include" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\pango-1.0" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\atk-1.0" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\include\gdk-pixbuf-2.0" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-2.0\include" -I"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -c C:\Users\wajnberg\Desktop\test\main.c -o obj\Debug\main.o
gcc.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -o bin\Debug\test.exe obj\Debug\main.o   -lgtk-win32-2.0 -lgobject-2.0 -lglib-2.0 "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gobject-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\pango-1.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gdk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\cairo.lib"
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgtk-win32-2.0.dll.a when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgtk-win32-2.0.dll.a when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgtk-win32-2.0.dll.a when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgtk-win32-2.0.dll.a when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-win32-2.0.lib when searching for -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgtk-win32-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgobject-2.0.dll.a when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgobject-2.0.dll.a when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgobject-2.0.dll.a when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libgobject-2.0.dll.a when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gobject-2.0.lib when searching for -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgobject-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libglib-2.0.dll.a when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libglib-2.0.dll.a when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libglib-2.0.dll.a when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/libglib-2.0.dll.a when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib/glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0.lib when searching for -lglib-2.0
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglib-2.0
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
4 error(s), 0 warning(s) (0 minute(s), 1 second(s))
 

GTK is installed here: C:\Program Files (x86)\CodeBlocks\MinGW\gtk

Thanks in advance for your help!

Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #3 on: October 22, 2020, 12:14:29 pm »
The "skipping incompatible library" error is shown because you are trying to link with libraries created with other compilers. The .lib are probably from Visual Studio and the .dll.a from other version or GCC (or the same version with different number of bits, 64 vs 32). You must create those libs with the same compiler and options used when compiling your program.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #4 on: October 22, 2020, 02:42:01 pm »
The "skipping incompatible library" error is shown because you are trying to link with libraries created with other compilers. The .lib are probably from Visual Studio and the .dll.a from other version or GCC (or the same version with different number of bits, 64 vs 32). You must create those libs with the same compiler and options used when compiling your program.
Thanks, but I do not see how this can be the explanation.

First of all, I'm not the one that compiled the GTK library. I took binaries already available for Windows. Second, as I said, I already installed this same GTK library on the same computer, with the same Windows version before, without any problem. So, I do not think the problem is coming from the library.

The only difference between what I did before, on the same machine, and what I'm trying to do now, is that I now use a new version (updated) of Code:Blocks, that maybe comes with a new version of gcc. For example, the GTK library is in 32 bits (I assume this is what the "win32" means), while I indeed install a 64 bits version of Code:Blocks. Can this be a possible explanation of the problem I have?

In all cases, thanks for your time and help on this.

Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #5 on: October 22, 2020, 03:09:04 pm »
C::B 20.04 bundles a new compiler (minGW-64 vs TDM), and it seems incompatible with the one used to build the libraries. Probably the bundled compiler generates 64-bit object files by default, or the ABI is different. Check which compiler was used to build you prebuilt libraries or build your own.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #6 on: October 22, 2020, 03:16:04 pm »
I can't know what compiler was used to build the GTK library that I have. I also can't built my own. It remains that, about two years ago, I was able to compile everything. For sure, at the time, the Code:Blocks version was different.

On the Code:Blocks "download" site, I just see that there is also a 32 bits version available (and I assume it comes with a 32 bits version of gcc). Do you think this could save me?

Again, thanks for your help.

Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #7 on: October 22, 2020, 04:13:29 pm »
You can install any compiler and set C::B to use it, you just need some care setting the PATH variable if compiling out of C::B.

Where did you download the binaries from? May be you can get some compiler info there.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #8 on: October 22, 2020, 04:19:14 pm »
I simply downloaded the bundle here: http://www.codeblocks.org/downloads/26 (from the CodeBlocks web site). There is a bundle that comes with a gcc version, all included.

Ok, I'll try to install the 32 bit version of this bundle and see what it gives.

I will report what it gives here.

Cheers, Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #9 on: October 22, 2020, 04:38:57 pm »
Sorry for not being clear, I was asking for the origin of the GTK prebuilt libraries.

About C::B, I would do the following:
  - Uninstall C::B 20.03 and the bundled compiler
  - Install the last nightly build from http://forums.codeblocks.org/index.php/topic,24160.0.html
  - Download a compiler from https://sourceforge.net/projects/mingw-w64/files/ (select Toolchains targetting Win32 or Win64, depending on your needs)
  - Install the compiler in C:\MinGW
  - Configure GCC Compiler in C::B so it uses the new compiler

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #10 on: October 22, 2020, 04:56:06 pm »
Ok. The GTK library comes from here: http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/  (hence the file gtk+-bundle_2.24.10-20120208_win32.zip). I definitely need this particular one.

I'll try the chain of actions you proposes me.

Strange that the Code:Blocks bundle about two years ago was working, but the new one is not. Actually, I should say the gcc I've downloaded about two years ago, etc..

I will keep on reporting what it gives, here.

Eric.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #11 on: October 22, 2020, 05:14:33 pm »
I never installed Code:Blocks like this. I've downloaded and extracted the zip (well 7Z) file indicated on the web page you gave me. But then? I can't run codeblocks.exe. What shall I do?

Alternatively, I know how to download Code:Blocks without a compiler. Shall I do that and then follow your procedure at step 3?

Again, thanks for your help on that.

Eric.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #12 on: October 22, 2020, 05:24:14 pm »
In the meantime, I was able to find that everything was working before on my computer with Code:Blocks version 16.01, and I also discovered that this version is still available here: https://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/, including with a compiler.

I guess I simply should install that one, and everything should be solved..

No?

Eric.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: GTK in Code:Blocks (Windows 10)
« Reply #13 on: October 22, 2020, 05:46:23 pm »
So, here is what I did:

I've finally installed the version 16.01 of Code:Blocks and everything works fine (finally!!).

So, the problem was indeed that the compiler - by default - provided in the bundle for Code:Blocks is a 64 bits version, while I was willing to link my codes with a 32 bits library.

This is fine, I should have notice this myself.

However, there remains a problem here:

If you go in the download page of Code:Blocks for the last version 20.03, you can still download a bundle for a 32 bit version, but there is no 32 bits version of gcc that comes with it. There is a mistake here, I think, and this should be said somewhere. No?

In all cases, the problem is solved (although with an old version of Code:Blocks).

Thanks for your help on this.

Cheers, Eric.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: GTK in Code:Blocks (Windows 10)
« Reply #14 on: October 22, 2020, 07:09:51 pm »
To install the nightly you must download and expand three 7z files, not one.

You can use the nightly with the compiler bundled with C::B 16.01 (TDM 5.1) without uninstalling 16.01.