Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:39:02+00:00 2026-05-26T10:39:02+00:00

I’m new in objective-c and makefiles, currently I’m trying to get an objective-c and

  • 0

I’m new in objective-c and makefiles, currently I’m trying to get an objective-c and Gtk+ “hello world” to compile via make.
The make code is as follows

# Suffixes

.SUFFIXES: .o .m
.m.o:
    $(CC) -c $(CFLAGS) $<

# Macros 
CC = gcc
CFLAGS = -g
GTKFLAGS= `pkg-config --cflags --libs gtk+-2.0`
LIBS = -lobjc
SRC = main.m  MainWindow.m
OBJ = main.o MainWindow.o
PROG = gnulog514

# Explicit rule
all: hist

hist: $(OBJ)
    $(CC) $(CFLAGS) -o main $(OBJ) $(GTKFLAGS) $(LIBS)

# Implicit rules
MainWindow.o: MainWindow.h MainWindow.m 

and I get the following output after make.

gcc -c -g main.m
In file included from main.m:1:0:
MainWindow.h:1:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make: *** [main.o] Error 1

Anything else you may need just ask.

UPDATE:

I’ve got something else that may help,
when issuing the command

$ gcc `pkg-config --cflags --libs gtk+2.0` -lgnustep-base -fconstant-string-class=NSConstantString -o "./myprogram" $(find . -name '*.m') -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -std=c99 -O3

(Got the error gtk+2.0 to gtk+-2.0)I get the following output

Package gtk+2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+2.0' found
In file included from ./main.m:1:0:
./MainWindow.h:1:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
In file included from ./MainWindow.m:1:0:
./MainWindow.h:1:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.

I’ll get that fixed and come back here to keeping updated this question until solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:39:02+00:00Added an answer on May 26, 2026 at 10:39 am

    I got it to work. Long story short instead of using Foundations headers I use objc headers.

    My Makefile looks like that

    # Suffixes
    %.o : %.m
        $(CC) $(CCFLAGS) $(CCGTK) -c -o $@ $^
    
    # Macros
    CC = gcc
    CCFLAGS = -lobjc
    CCGTK = `pkg-config --cflags --libs gtk+-2.0` 
    SOURCES= $(wildcard *.m) 
    OBJECTS= $(SOURCES:.m=.o)
    PROG = glog514
    
    # Targets
    all: $(SOURCES) $(PROG)
    
    $(PROG): $(OBJECTS)
        $(CC) -o $@ $(OBJECTS) $(CCFLAGS) $(CCGTK) 
    
    clean:
        rm -f $(OBJECTS) $(PROG)
    

    And if you want to try by yourself my main.m

    #import "MainWindow.h"
    
    int main(int argc, char *argv[]) {
    
      //init gtk engine
      gtk_init(&argc, &argv);
    
      //set up GUI
      MainWindow *mainWindow = [[MainWindow alloc] initWithArgCount:&argc ArgVals:argv];
    
      //begin the GTK loop
      [mainWindow startGtkMainLoop];
    
      //free the GUI
      [mainWindow free];
    
      //exit application
      return 0;
    }
    

    my MainWindow.h

    #include <objc/Object.h>
    #include <gtk/gtk.h>
    
    id myMainWindow;
    
    @interface MainWindow:Object
    {
      // Main GTKWindow
      GtkWidget *mainWindow;
      GtkWidget *button;
    }
    
    -(id)initWithArgCount:(int *)argc ArgVals:(char *[])argv;
    
    -(void)destroyWidget;
    
    -(void)startGtkMainLoop;
    
    -(void)printSomething;
    
    void on_MainWindow_destroy(GtkObject *object, gpointer user_data);
    
    void on_btnPushMe_clicked(GtkObject *object, gpointer user_data);
    
    @end
    

    my MainWindow.m

    #include "MainWindow.h"
    #include <gtk/gtk.h>
    
    @implementation MainWindow
    
    
    -(id)initWithArgCount:(int *)argc ArgVals:(char *[])argv {
      //call parent class’ init
      if (self = [super init]) {
        //setup the window
        mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    
        gtk_window_set_title (GTK_WINDOW (mainWindow), "Hello World");
        gtk_window_set_default_size(GTK_WINDOW(mainWindow), 230, 150);
    
        //setup the button
        button = gtk_button_new_with_label ("Push me!");
    
        gtk_container_add (GTK_CONTAINER (mainWindow), button);
    
        //connect the signals
        g_signal_connect (mainWindow, "destroy", G_CALLBACK (on_MainWindow_destroy), NULL);
        g_signal_connect (button, "clicked", G_CALLBACK (on_btnPushMe_clicked), NULL);
    
        //force show all
        gtk_widget_show_all(mainWindow);
      }
    
      //assign C-compatible pointer
      myMainWindow = self;
    
      //return pointer to this object
      return self;
    }
    
    -(void)startGtkMainLoop {
      //start gtk loop
      gtk_main();
    }
    
    -(void)printSomething{
    
    }
    
    -(void)destroyWidget{
      myMainWindow = NULL;
    
      if(GTK_IS_WIDGET (button)){
        //clean up the button
        gtk_widget_destroy(button);
      }
    
      if(GTK_IS_WIDGET (mainWindow)){
        //clean up the main window
        gtk_widget_destroy(mainWindow);
      }
    }
    
    -(void)dealloc{
      [self destroyWidget];
    
      [super dealloc];
    }
    
    void on_MainWindow_destroy(GtkObject *object, gpointer user_data){
      //exit the main loop
      gtk_main_quit();
    }
    
    void on_btnPushMe_clicked(GtkObject *object, gpointer user_data){
      printf("Button was clicked\n");
    
      //call Objective-C function from C function using global object pointer
      [myMainWindow printSomething];
    }
    
    @end
    

    Just put all the files in the same folder and run make, you’ll get a compiled file called glog514, then execute it and you’ll get the nice gtk window.

    ./glog514

    cheers,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.