LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-02-2005, 05:16 PM   #1
BBB
Member
 
Registered: Aug 2004
Location: sweden
Distribution: Slackware 10.2 and Win2k
Posts: 127

Rep: Reputation: 15
Whats wrong with "my" makefile?


Hi!
Im currently learning linux programming and ive come across a library tutorial:
http://users.actcom.co.il/~choo/lupg...ynamic-shared/
( http://users.actcom.co.il/~choo/lupg...ynamic-shared/ )

Ive downloaded all files but when i type "make" in the consoles it sez:
"Makefile:35 *** missing separator. stop."
Ive looked at line 35 in the makefile and it looks fine as far as I know.

Here is the makefile (you can download the entire program from the link):

Code:
# Compiler/Linker/dynamic linker
CC = gcc
LD = gcc

# flags to compile object files that can be used in a dynamic library
CFLAGS = -fPIC
# on some platforms, use '-fpic' instead.

# Flags to create a dynamic library.
DYNLINKFLAGS = -shared -nostdlib
# on some platforms, use '-G' instead.

# files removal
RM = /bin/rm -f

# program's object files
PROG_OBJS = main.o

# program's executable
PROG = prog

# libraries to link with the program during compile time.
LIBS = -ldl

# shared library files
LIB_FILES = lib1.so lib2.so

# shared libraries object files
LIB_OBJS = lib1.o lib2.o

# top-level rule
all: $(LIB_FILES) $(PROG)

$(PROG): $(PROG_OBJS)
$(LD) $(LDFLAGS) $(PROG_OBJS) $(LIBS) -o $(PROG) # <- this is the incorrect line -------------

# create our librarys
lib1.so: lib1.o
$(LD) $(DYNLINKFLAGS) $< -o $@

lib2.so: lib2.o
$(LD) $(DYNLINKFLAGS) $< -o $@

# compile C source files into object files.
%.o: %.c
$(CC) $(CFLAGS) -c $<


# clean everything
clean:
$(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)

# clean the program and its object files, don't touch the library.
cleanprog:
$(RM) $(PROG_OBJS) $(PROG)

# clean the library and its object files only
cleanlib:
$(RM) $(LIB_OBJS) $(LIB_FILES)

# clean the library's object files only
cleanlibobjs:
$(RM) $(LIB_OBJS)

Last edited by BBB; 03-02-2005 at 05:21 PM.
 
Old 03-02-2005, 05:30 PM   #2
linuxzealot
Member
 
Registered: Feb 2005
Distribution: Gentoo
Posts: 57

Rep: Reputation: 15
You need a tab on that line, makefiles use tabs instead of spaces.

So try changing
Code:
clean:
$(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)
to
Code:
clean:
	$(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)

Last edited by linuxzealot; 03-02-2005 at 05:46 PM.
 
Old 03-02-2005, 05:47 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Note that you need a tab on all those command lines.
 
Old 03-02-2005, 05:51 PM   #4
linuxzealot
Member
 
Registered: Feb 2005
Distribution: Gentoo
Posts: 57

Rep: Reputation: 15
I was gonna say that, but I figured he would of eventually found out
 
Old 03-02-2005, 05:53 PM   #5
BBB
Member
 
Registered: Aug 2004
Location: sweden
Distribution: Slackware 10.2 and Win2k
Posts: 127

Original Poster
Rep: Reputation: 15
Yay it works! I had to add some stuff to the makefile
(wierd ,unfinished tutorial...) but it seems to be working
fine. Thx for the help!
 
  


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
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
"no targets specified and no makefile found" liljhand Linux - Software 9 01-01-2005 12:54 PM
How can I use "Makefile.in" for building an executable program? wuzhong Linux - Networking 1 10-06-2004 10:00 AM
"perl Makefile.PL" complains about cc & gcc (self solved tip) Raptor Ramjet Slackware 2 09-13-2004 02:24 PM
how does a "makefile" relate to the make command? mjewell Linux - Newbie 3 01-17-2004 08:27 PM

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

All times are GMT -5. The time now is 03:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration