C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-05-2001, 04:58 PM   #1
Unregistered
Guest
 
Posts: n/a
creating make files

can someone please give me an example of a makefile. what i am trying to do is compile two files with gcc by using the make comand. right now i have

all:
gcc -o file1 file1.c
gcc -o file2 file2.c


and if i issue the make command i get

make: Fatal error in reader: Makefile, line 3: Unexpected end of line seen

help!!!
thanks.
  Reply With Quote
Old 09-05-2001, 08:11 PM   #2
Registered User
 
Join Date: Aug 2001
Posts: 79
Are you trying to compile two programs, or simply compile a single program that has two .c source files?

Either way, you're not supposed to generate the Makefile yourself. You generate the Makefile.am and the configure.in(I think. There might be programs to help. I'm rather new to programming in Linux).

type:
$info automake

In the former case, examples->ctags&etags is a good example.

In the latter case, either use a different example or just read the rest of the docs(which are better than your average info help).
__________________
All generalizations are false
Flarelocke is offline   Reply With Quote
Old 09-05-2001, 10:08 PM   #3
Registered User
 
Xaviar Khan's Avatar
 
Join Date: Sep 2001
Posts: 10
Talking actually...

Actually,
You can and should create your own make file. Just to be sure you know what you want.

I'm using Redhat Linux 6.2 on an i686
not sure if that would affect your makefile any, but the type of OS you are running would no doubt have an effect on the syntax of the things you use.

Here's a look at my makefile.
Code:
CC      = gcc
PROF    =
OPTOMIZ = -O2
DEBUG   = -g3
WARN    = -Wall
#C_FLAGS = $(PROF) $(OPTOMIZ) $(WARN) $(DEBUG)
C_FLAGS = -c -O -Wall -g3
L_FLAGS = -static -g
CRYPT   = -lcrypt
SYSTEM  =

O_FILES = act_comm.o act_info.o act_move.o blah blah blah
(i'm not sure you need the names of my '.o' files... but here is wher you put your files to be compiled)  be sure to leave a '~' at the end or bad things will happen ;)
I'm also using the concurrent versioning system (CVS) so things are subject to changes if you are not.

HTH
__________________
Xaviar Khan
Programmer/Owner
Shards of Destiny (SoD)
---------------------------------------
Reach us with any MUD client at ShardsofDestiny.org
port 9000.
+------------------------------------+
| Html/Java support added, |
| 'www.ShardsofDestiny.org' |
+------------------------------------+
Xaviar Khan is offline   Reply With Quote
Old 09-06-2001, 02:52 PM   #4
Registered User
 
Strider's Avatar
 
Join Date: Aug 2001
Posts: 149
Your best bet is to be very specific and break it down into the separate parts.

Code:
#######################################
#
# Makefile
#

FILES = file1.c file2.c

OBJECTS = file1.o file2.o

all:      $(OBJECTS)
          gcc -o NameOfExecutable $(OBJECTS)

file1.o:  $(FILES) $(OBJECTS)
          gcc -c file1.c

file2.o:  $(FILES) $(OBJECTS)
          gcc -c file2.c
Also make certain there is no CrLf after the last item.

David
__________________
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.

Last edited by Strider; 09-06-2001 at 02:54 PM.
Strider is offline   Reply With Quote
Old 09-22-2001, 01:58 AM   #5
vickyloveslinux@yahoo.com
Guest
 
Posts: n/a
a simple hint with the last example



parameter_name : dependent files (a.out and the files you'll use )
<tab very imp ok> commands



enjoy
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how gnu make tells if file's been changed? thinhare C Programming 2 03-19-2008 03:10 AM
Make Files shipyard C Programming 6 03-13-2005 12:43 PM
creating multiple files lime C Programming 8 01-01-2004 02:55 PM
How To Make The Program Installed In Program Files Folder? javacvb Windows Programming 4 11-05-2003 05:33 PM
Creating files then Hiding them or making them Read-Only...how? Kyoto Oshiro C++ Programming 7 03-09-2002 07:30 PM


All times are GMT -6. The time now is 01:55 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22