Code::Blocks

User forums => Help => Topic started by: arkkimede on April 22, 2018, 02:17:20 am

Title: How to use CB with GTK3 on Windows 10
Post by: arkkimede on April 22, 2018, 02:17:20 am
Probably this is a question yet done a lot of times.
I followed the instructions reported in the www.gtk.org but installing MSYS2 and following the instruction I obtain a lot of errors.
What I ask is to redirect toward a page where is reported how to install GTK3 on Windows 10 and use it with Code Blocks.

Thank you for your patience.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: BlueHazzard on April 22, 2018, 02:35:59 am
without exact error messages no help sry.....
if you have compiler errors, please note also:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on April 22, 2018, 03:25:23 am
The error is not on CB but installing all the component of GTK
The error is:
download to slow error
and the package is skipped.

Is not possible to download ALL GTK3 in a only and single files?

Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on April 22, 2018, 04:32:45 am
So, ask for help from your Internet Service provider.

Please read and follow the rules.
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)

Note: If you post a direct link to the directions you tried to follow; I might try the directions and see if they work.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on April 22, 2018, 04:46:34 am
Found the directions https://www.gtk.org/download/windows.php (https://www.gtk.org/download/windows.php)

Quote
Step 1: Install MSYS2

The likely off topic problem is you failed to update MSys2 as part of step 1 of the directions.

But, I am thinking this is too off topic to help you get MSys2 installed.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on April 22, 2018, 03:45:06 pm
Found the directions https://www.gtk.org/download/windows.php (https://www.gtk.org/download/windows.php)

Quote
Step 1: Install MSYS2

The likely off topic problem is you failed to update MSys2 as part of step 1 of the directions.

But, I am thinking this is too off topic to help you get MSys2 installed.

Tim S.

Link to off site directions that might help with step 1
https://github.com/stahta01/cb_misc/blob/master/Notes/MSys2/How%20update%20MSys2%20under%20windows%2010.txt (https://github.com/stahta01/cb_misc/blob/master/Notes/MSys2/How%20update%20MSys2%20under%20windows%2010.txt)

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 04, 2018, 10:50:04 pm
At this moment all the environment and installation of MSYS2 is correct.
I've installed MSYS2 for 64 bit machine.

If I use it like unix, the application written on UBUNTU is compiled linked and it run correctly.

Now I want to use CB.

The first question is related to the wizard of GTK.
If on the icon of GTK you select right button it is possible to edit it.

It refers to GTK2 and not GTK3 and search win32 library

So: it is possible to modify the wizard in order to use GTK3 and it can works whit 64 bit or I have to install MSYS2 with 32bit?
thanks

 
Title: Re: How to use CB with GTK3 on Windows 10
Post by: BlueHazzard on May 05, 2018, 01:06:47 am
Quote
So: it is possible to modify the wizard in order to use GTK3 and it can works whit 64 bit or I have to install MSYS2 with 32bit?
thanks
of corse it is possible...

but you don't need the script to create a gtk project, just make it by your own. But it think you have also set up a msys compiler

stahta01 can help you here...
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 02:09:26 am
I will try to setup an project using GTK3 and MSys2 32 bit under Windows 10.
The wxWidgets projects I do it does not matter whether it is MSys2 MinGW 32 bit or 64 bit.
It should be the same for GTK3 projects.

Edit: Once, I started I remembered I did this several days ago.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 02:22:49 am
Unzip the file attached and try building it.
It might work; but, I will likely have to give you directions on how to setup the MSys2 MinGW GCC Compiler in Code::Blocks.
Note: To me it is clear how to setup Code::Blocks; but, newbies have a lot of problems.
I am now an expert on setting up GCC based compilers in C::B.

Edit: Link to C::B Project without the adding of main.c to it. https://github.com/stahta01/MSys2_CodeBlocks_Projects/tree/master/gtk (https://github.com/stahta01/MSys2_CodeBlocks_Projects/tree/master/gtk)

Edit2: Packages install command for 32 bit; change "i686" to "x86_64" for 64 bit.
Code: [Select]
pacman -S --needed --asdeps mingw-w64-i686-gcc mingw-w64-i686-gtk3

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 05, 2018, 02:43:26 pm
I tried to compile your minimal code but error occur (C::B does not find gtk/gtk.h (see attached error.png).
I tried to update the MSYS2 environment but it it up to date (see attched update.png)
Looking in the cbp file I've see this line of code:
<Add directory="$(TARGET_COMPILER_DIR)include/gtk-$(GTK_VERSION)" />
but $(TARGET_COMPILER_DIR) is not specified so in the same file in the section environment I modified so:
<Environment>
            <Variable name="ATK_VERSION" value="1.0" />
            <Variable name="GLIB_VERSION" value="2.0" />
            <Variable name="GTK_PIXBUF_VERSION" value="2.0" />
            <Variable name="GTK_VERSION" value="3.0" />
            <Variable name="PANGO_VERSION" value="1.0" />
            <Variable name="TARGET_COMPILER_DIR" value="C:/msys64/mingw64/" />
</Environment>
but nothing change.

I do not know what else to try.
Thank you in any case for your suggestions and support
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 04:04:17 pm
TARGET_COMPILER_DIR is a built in user variable do NOT define it.

Post your compiler settings!!

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 04:09:54 pm
32 Bit Compiler Settings

Code: [Select]
Installation Directory: C:\msys32\mingw32

C Compiler:             i686-w64-mingw32-gcc.exe
C++ Compiler:           i686-w64-mingw32-g++.exe
Linker for Dyn. Libs:   i686-w64-mingw32-g++.exe
Linker for Static Libs: ar.exe
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 04:53:10 pm
64 Bit Compiler Settings

Code: [Select]
Installation Directory: C:\msys64\mingw64

C Compiler:             x86_64-w64-mingw32-gcc.exe
C++ Compiler:           x86_64-w64-mingw32-g++.exe
Linker for Dyn. Libs:   x86_64-w64-mingw32-g++.exe
Linker for Static Libs: ar.exe
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 05, 2018, 06:23:26 pm
Thank You stahta01!
I had a wrong path to another mingw-64 compiler.
I'm now able to build and run your minimal code.

In the future, if I want to build another project, what I have to do?


And just another info:
How to add all the library need (cairo, gdk_pixbuf, etc): I have to add all the .dll or .a file in the section
Settings->Compiler->Linker Setting-> Add link library
or in other way?


Thank You again.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 07:51:30 pm
The wizard does NOT work for using the MSys2 mingw GCC compiler.

I would just save this project as a template and use the Template option in C::B.

The other questions should be answered by the Wiki and FAQs.
http://wiki.codeblocks.org/index.php/FAQ (http://wiki.codeblocks.org/index.php/FAQ)

If you do not know if the option should be added to the Compiler Global Settings or to the project settings; pick the project settings.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: BlueHazzard on May 05, 2018, 08:15:03 pm
We should add support for the msys compiler with autodetection
and also in the scripts if msys is selected we simply can add the libraries, without search path and so on, because this is always the same and can be added to the compiler options...
We could even call pacman automatically in the wizard script if the package is not installed...

I don't think that this is hard to do? Msys is definitively the future on windows... pacman is a bless....
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 09:45:16 pm
We should add support for the msys compiler with autodetection

Edit: I was hoping the Compiler code had changed enough that the changes was just in XML files.

Too hard for me to do; the last time I tried this one of the Devs said no because they did not like the way I did it.
I agree that my method was not very good.

If I figure out a better way; I might try to create a patch.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 05, 2018, 10:11:39 pm
and also in the scripts if msys is selected we simply can add the libraries, without search path and so on, because this is always the same and can be added to the compiler options...

Creating an GTK2 project now; after I get the project to work, I will look at the C::B GTK wizard.

Edit: C::B Wizard just need very minor fix for GTK2; so, I do that fix and then see how to add GTK3 support.
Edit2: I plan to test GTK2/3 under Linux and then see if it works the Wizard code has several sections commented out for Linux.

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 06, 2018, 01:11:49 am
Quote
The wizard does NOT work for using the MSys2 mingw GCC compiler.

I would just save this project as a template and use the Template option in C::B.

The other questions should be answered by the Wiki and FAQs.
http://wiki.codeblocks.org/index.php/FAQ

If you do not know if the option should be added to the Compiler Global Settings or to the project settings; pick the project settings.

Tim S.

I tried to add library and path to search and for the function related to cairo I solved but for
pixbuf = gdk_pixbuf_new_from_file(filename, &error);
no!.
I report the error and the search dir and library for link in 3 different msg for the limits of the attachement
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 06, 2018, 01:15:02 am
pictures
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 06, 2018, 01:15:48 am
Pictures link options
Title: Re: How to use CB with GTK3 on Windows 10
Post by: arkkimede on May 06, 2018, 01:16:28 am
pictures search dirs
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 06, 2018, 02:10:38 am
Please post a build log in code tags.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 06, 2018, 02:15:02 am
You are not adding libraries in the normal Code::Blocks manner.

Quote
For your project :
- Right click on the project then select Build options
- Select the directories tab
- Add the required paths for compiler and linker.
- Add your specific libraries in the linker tab.
- Pay attention to project settings and target settings.

From http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)

Tim S.
Title: Re: How to use CB with GTK3 on Windows 10
Post by: stahta01 on May 06, 2018, 02:16:22 am
How to report compiling problems
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)
Title: Re: How to use CB with GTK3 on Windows 10 (Solved)
Post by: arkkimede on May 07, 2018, 07:00:22 pm
Now I'm finally able to compile and run a complete app with GTK3 on Windows 10 using C::B.

The solution is to put in the linker setting, other link options
`pkg-config --libs gtk+-3.0`

Thank you in any case for the support and the time that you have spent for me.