Author Topic: Codeblocks on MacOS with GTK  (Read 538 times)

Offline johanneshau

  • Single posting newcomer
  • *
  • Posts: 2
Codeblocks on MacOS with GTK
« on: April 16, 2022, 11:25:11 am »
Hi there,

I am new to the CodeBlocks forum. I could not find a solution to my problem by searching the forum.

The problem is:

I have created a new GTK project using the "New Project Wizard".When I try to compile I get the error "fatal error: 'gtk/gtk.h' file not found"
(output of "Build messages" window):

Code
||=== Build: Debug in gtk-test (compiler: GNU GCC Compiler) ===|
/Users/jh/prog/gtk-test/main.c|2|fatal error: 'gtk/gtk.h' file not found|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I do have `pkg-config gtk+-2.0 --cflags` in "Project build options":

<see attachment "screenshot_project-options.png">

But apparently pkg-config is not called by the compiler
(output of "Build log" window):

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

gcc -Wall -g  -c /Users/jh/prog/gtk-test/main.c -o Debug/main.o
/Users/jh/prog/gtk-test/main.c:2:10: fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
         ^
1 error generated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

When I run "pkg-config gtk+2 --cflags" inside Terminal the response seems reasonable to me:
 
<see attachment "screenshot_pkg-config-in-terminal.png">

When I change `pkg-config gtk+-2.0 --cflags` in the "Project build options", e.g. remove the backticks, I get (expected) errors.
(output of "Build Messages" window):

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

gcc -Wall pkg-config gtk+-2.0 --cflags -g  -c /Users/jh/prog/gtk-test/main.c -o Debug/main.o
clang: error: unsupported option '--cflags'
clang: error: no such file or directory: 'pkg-config'
clang: error: no such file or directory: 'gtk+-2.0'
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

So it seems that the contents of "Other options" are processed by CodeBlocks.

I use CodeBlocks 13.12 on a Macbook "Late 2008" running OSX 10.9.5 (Mavericks).
I have installed the GTK libs etc. via Macports and I am able to compile and link applications via a Makefile in Terminal.

Btw. how do I add a screenshot (or any other image) inline in a post? The "Insert Image" button just adds tags to the text.

Do I have to set some additional configurations in CodeBlocks?
Is there the possibility to set custom search directories for a certain type (e.g. GTK) of project?
Where and how would I do this?

Please advise.

Thanks al lot!

Johannes

Offline AndrewCot

  • Regular
  • ***
  • Posts: 474
Re: Codeblocks on MacOS with GTK
« Reply #1 on: April 16, 2022, 11:48:22 am »
I had similar issues with pkg-config when I build C::B from source on a MAC earlier this year. I changes the pkg-config to /usr/local/bin/pkg-config and I could then build C::B. I did not investigate what the root cause was.

C::B 13.12 is very old. You may want to try to see if you can use the latest nightly build on your OSX, but it may be not work. Sorry I am not a MAC guru. Good luck with upgrading.

Offline johanneshau

  • Single posting newcomer
  • *
  • Posts: 2
Re: Codeblocks on MacOS with GTK
« Reply #2 on: April 17, 2022, 07:49:32 am »
AndrewCot, thanks for the tip. I made a symbolic link of /opt/local/bin/pkg-.config to /usr/local/bin/pkg-config but this did no change anything.
I run version 13.12 because it seems to be the latest version which runs on MacOS 10.9 (Mavericks). I know it is quite old, but the Macbook I am working with is old as well and I am not able to upgrade this.
Thank you anyway.