Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


Search this Thread
Old 05-08-2013, 08:30 AM   #1
LQ Newbie
Registered: Sep 2012
Location: Orlando, FL
Posts: 7

Rep: Reputation: Disabled
Makefile question?

I have a Makefile with:
.PHONY: all clean distclean

all: $(LEXFILE) $(BINDIR)/$(APP)
LEXFILE := lex.yy.c
APP = bridge
BINDIR = bin
If I redefine:
all: $(LEXFILE) $(OBJDIR)/%.o
OBJDIR = obj
I get: make: *** No rule to make target `obj/%.o', needed by `all'. Stop.

Old 05-08-2013, 08:56 AM   #2
Senior Member
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,740

Rep: Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265
the line all: $(LEXFILE) $(OBJDIR)/%.o is syntactically correct, but will not do what you want, you would need to check the documentation about how to use %.
In your case make is looking for a file named %.o in the dir obj.
Usually you need something like that:
%.ext1: %.ext2 where % can be replaced with a filename using ext1 and ext2 as target(result) and source.
Old 05-09-2013, 02:14 AM   #3
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,772

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Well, what did you mean by $(OBJDIR)/%.o? What should make have substitute with?


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
makefile question ryande Linux - General 5 04-30-2010 12:11 AM
Makefile question silentray Linux - Newbie 1 12-18-2009 04:51 AM
g++ makefile question zahadumy Programming 4 03-25-2007 04:18 PM question lucky6969b Programming 4 12-08-2005 03:32 AM
Question about makefile taureanyang Programming 1 03-25-2005 11:57 PM

All times are GMT -5. The time now is 09:11 AM.

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