LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 04: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, 04:32 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

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

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, 04:54 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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



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 05:48 PM
Make files disruptive Programming 5 12-02-2005 09:33 PM
Building evolution 1.2.1: make error Hcman Linux - Software 5 02-16-2003 06:02 AM
Make files rao Programming 3 07-18-2002 01:20 PM
Building RPM files from TAR files parle Linux - Software 3 05-05-2002 11:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration