LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-27-2006, 05:29 PM   #1
red_hax0r
LQ Newbie
 
Registered: Jun 2006
Posts: 12

Rep: Reputation: 0
Angry Building make files


Whaat is the simplist makefile I can design to compile a single gtk program?

Here's what I have...


hello: hello.c
gcc hello.c -o hello


It gives me an error:

makefile:2: *** missing separator. Stop.
 
Old 06-27-2006, 05:32 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
try putting a tab on the second line... or any line that starts with gcc.
 
Old 06-27-2006, 05:53 PM   #3
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
As nadroj said, every action needs to start with a tab for histerical raisons.
Another good idea is to take advantage of make's implicit rules.
Code:
CC = gcc
CFLAGS = -g -Wall
hello:
make will compile the program using CC and with CFLAGS, which are to compile with debug info and turn on all warnings.
 
Old 06-28-2006, 05:54 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Here's a simple 'Makefile' to compile and link the 'helloworld.c' exmaple from the GTK2 tutorial:
Code:
CC = gcc
CFLAGS = -g -Wall `pkg-config --cflags gtk+-2.0`
LIBS =  `pkg-config --libs gtk+-2.0`

helloworld: helloworld.o
	$(CC) $(LIBS) -o helloworld helloworld.o

helloworld.o: helloworld.c
	$(CC) $(CFLAGS) -c -o helloworld.o helloworld.c
Please note that, as nadroj and tuxdev already pointed out, the empty spaces in front of the lines that begin with "$(CC)" must be TABS.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
KDevelop not building files sghod1212 Mandriva 2 12-22-2005 06:48 PM
Make files disruptive Programming 5 12-02-2005 10:33 PM
Building evolution 1.2.1: make error Hcman Linux - Software 5 02-16-2003 07:02 AM
Make files rao Programming 3 07-18-2002 02:20 PM
Building RPM files from TAR files parle Linux - Software 3 05-06-2002 12:02 AM


All times are GMT -5. The time now is 12:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration