GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 16, 2014 12:54 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Can not build a simple program
PostPosted: Thu Oct 13, 2011 6:05 pm 
Offline

Joined: Thu Oct 13, 2011 5:50 pm
Posts: 3
Here is my makefile:
all:
gcc -Wall $(pkg-config --cflags gtk+-2.0) -o statusbar.o -c statusbar.c
gcc -Wall $(pkg-config --libs gtk+-2.0) -o statusbar -c statusbar.o

Here is the error:
gcc -Wall -o statusbar.o -c statusbar.c
statusbar.c:2: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make: *** [all] Error 1

#locate gtk.h
/usr/include/gtk-2.0/gtk/gtk.h

#pkg-config --cflags gtk+-2.0
-pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12

The #includes from the program:
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib.h>

I must be missing something.
Bob


Top
 Profile  
 
 Post subject: Re: Can not build a simple program
PostPosted: Thu Oct 13, 2011 6:59 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the GTK+ forums.

rlp1938 wrote:
Here is my makefile:
all:
gcc -Wall $(pkg-config --cflags gtk+-2.0) -o statusbar.o -c statusbar.c
gcc -Wall $(pkg-config --libs gtk+-2.0) -o statusbar -c statusbar.o

I don't think make understands $() notation. You should probably use backticks or $(shell ) notation. Your example code should look somewhat like this:
Code:
all:
   gcc -Wall $(shell pkg-config --cflags gtk+-2.0) -o statusbar.o -c statusbar.c
   gcc -Wall $(shell pkg-config --libs gtk+-2.0) -o statusbar statusbar.o


Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: Can not build a simple program
PostPosted: Fri Oct 14, 2011 5:48 am 
Offline

Joined: Thu Oct 13, 2011 5:50 pm
Posts: 3
Quote:

I don't think make understands $() notation. You should probably use backticks or $(shell ) notation. Your example code should look somewhat like this:

Code:
all:
   gcc -Wall $(shell pkg-config --cflags gtk+-2.0) -o statusbar.o -c statusbar.c
   gcc -Wall $(shell pkg-config --libs gtk+-2.0) -o statusbar statusbar.o



You are right. Thank you!

Your makefile lines work and so do backticks.

Thanks,
Bob


Top
 Profile  
 
 Post subject: Re: Can not build a simple program
PostPosted: Wed Oct 19, 2011 6:03 am 
Offline
Familiar Face

Joined: Mon Apr 18, 2011 10:23 pm
Posts: 5
Code:
CC=gcc
CCFLAGS=-Wall `pkg-config --cflags --libs gtk+-2.0`

all:
    $(CC) $(CCFLAGS) -o statusbar.o -c statusbar.c
    $(CC) $(CCFLAGS) -o statusbar statusbar.o


or for all cases in life

Code:
CC=gcc
CCFLAGS=-Wall `pkg-config --cflags --libs gtk+-2.0`
PROGNAME=statusbar
SOURCES=statusbar.c

OBJECTS=$(SOURCES:.c=.o)

$(PROGNAME): $(OBJECTS)
    $(CC) $(CCFLAGS) -o $@ $^

$(OBJECTS): $(SOURCES)
    $(CC) $(CCFLAGS) -c $^

clean:
    rm -f $(OBJECTS) $(PROGNAME)



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group