help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a problem with GNU make


From: Paul D. Smith
Subject: Re: a problem with GNU make
Date: 13 Sep 2005 09:13:09 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

This is a good place for GNU make questions, but an even better place is
the help-make@gnu.org or bug-make@gnu.org mailing lists.  There is also
a make-w32@gnu.org mailing list specifically for DOS/Windows-related
questions.

I should point out that the version of GNU make that comes with the
Cygwin toolkit has been modified by the Cygwin folks: it's not the same
as the version that comes from the FSF.  We only support the FSF version
here and on the above lists so if your question relates to
Cygwin-specific issues you'll need to ask on a Cygwin mailing list.


I should also point out that you've left out too many details here.  I
understand wanting to keep the post to a reasonable size and if you post
too much detail no one will read it.  However, if you leave out critical
information it forces us to guess as to what the problem might be, which
is frustrating for all concerned.  For example, what is the value of
OBJ_DIR?  Also, sometimes you report messages that make printed, but it
seems like you're paraphrasing them instead of quoting them exactly.
Even small bits of punctuation often matter.

If this message doesn't help you, please reproduce your problem with a
very minimal, but COMPLETE, example makefile and post that, along with
the command you invoke and _exactly_ what make prints (cut and paste
please).


%% "a R T u n" <muratartun@gmail.com> writes:

  artun> I am trying to handle a software project comprised of several
  artun> source and header files. Source and header files are in
  artun> seperate directories called "src" and "include" respectively. I
  artun> want to place my object files under a seperate directory "obj"
  artun> and then link those object files to get the binary under the
  artun> "out" directory.

  artun> The makefile that I am using for this is:

  artun> %.obj : %.cpp
  artun>        @$(CC) $(CFLAGS) $<

The above pattern is not correct for what you want to do.  If you're
trying to compile $(OBJ_DIR)/foo.obj from $(SRC_DIR)/foo.cpp, your
target pattern needs to be:

    $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.cpp

You will probably find the doc on "How Not to use VPATH" on my web site
(in my sig) interesting reading.

  artun> I guess the reason for the error is the rule that runs the linker
  artun> cannot find all the object files that are given as prerequisities to
  artun> it. I also give the "obj" directory to vpath of course. To overcome
  artun> this, I tried:

  artun> $(OUTFILE) : $(OBJ_DIR)$(OBJECTS)

That won't work; if OBJECTS contains more than one value OBJ_DIR will
apply only to the first one.  You mean something like:

    $(OUTFILE) : $(addprefix $(OBJ_DIR)/,$(OBJECTS))

  artun> But this time I got an error from GNU make that "No rule to
  artun> make target firstfile.obj".

That can't be right, because it doesn't say anything about OBJ_DIR... I
assume OBJ_DIR is set to some value?

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


reply via email to

[Prev in Thread] Current Thread [Next in Thread]