help-gplusplus
[Top][All Lists]
Advanced

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

hel on GNU make


From: a R T u n
Subject: hel on GNU make
Date: 10 Sep 2005 07:21:05 -0700
User-agent: G2/0.2

I am sorry if my question is offtopic in this group. But there isn't
any dedicated group for GNU make. If there please let me know.

My problem with GNU make is managing a c++ project with several
modules. Specifically, what I want to do is to read sources from ./src
and header from ./include directories resoectively, and place the
objects under ./obj and output under ./out directories. The ./obj and
./out directories are created in the makefile if they do not exist.

The main part of my makefile to handle this is as below:

all: dirs $(OUTFILE)

$(OUTFILE) : $(OBJECTS)
        $(LD) $(LFLAGS) $<

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

.PHONY: dirs

dirs:
        -@if [ ! -d $(OBJ_DIR) ] ; then echo "Creating $(OBJ_DIR)"; mkdir
$(OBJ_DIR) ; fi
        -@if [ ! -d $(OUT_DIR) ] ; then echo "Creating $(OUT_DIR)"; mkdir
$(OUT_DIR) ; fi

Of course, necessary variable and vpath definitions are handled before
target all.

With this makefile, I can succesfully create the two directories if
they do ot exist, and compiple all the sources under ./obj directory.

However, when the link starts there happens weird things.

When I run the make for the first time it says LINK: fatal error 1181:
cannot open input file "firstfile.obj"

But when I run it for the second time the ouptut file is successfully
created.

I thought that the problem might be because of directory creation and
tried to run make with the output directories exist. But I got same
error message.

Then I deleted all the object files except the firstfile.obj. then ran
make. In this case it successfully perfomed the link.

Can anyone tell me what the problem is and how I can overcome it?

Thanks...



reply via email to

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