3

This is more of a specific question on a specific case.

Here is what I have:

SRC = \
  CartoCursor.cpp \
  CartoOperatorFactory.cpp \
  CurveHelper.cpp \
  $(NULL)

CXX = g++
CC_FLAGS = -fPIC -Wall
SYMB_OBJ_DIR = ./obj/symb_obj
SYMB_X_INCLUDE = -I../../../MYLIBS
SYMB_X_OBJS = $(SRC:%.cpp=$(SYMB_OBJ_DIR)/%.o)

all : libSymbolXLib.a

libSymbolXLib.a : $(SYMB_X_OBJS)
        rm -f $@


$(SYMB_OBJ_DIR)/%.o : %.cpp
        $(CXX) -c $(CC_FLAGS) $(SYMB_X_INCLUDE) -o $(INT_DIR)/$*.o $?

When I run this I am getting the following error:

make[1]: *** No rule to make target `obj/symb_obj/CartoCursor.o', needed by `libSymbolXLib.a'.  Stop.

What do I need to do to get the libSymbolXLib to recognize the generic build rule?

If this is not clear please let me know.


UPDATE

Using:

CXX = g++
CC_FLAGS = -fPIC -Wall
SYMB_OBJ_DIR = ./obj/symb_obj
SYMB_X_INCLUDE = -I../../../MYLIBS
SYMB_X_OBJS = $(SRC:%.cpp=$(SYMB_OBJ_DIR)/%.o)

all : libSymbolXLib.a

libSymbolXLib.a : $(SYMB_X_OBJS)
        ar rcs $@ $^

$(SYMB_OBJ_DIR)/%.o : %.cpp
        $(CXX) -c $(CC_FLAGS) $(SYMB_X_INCLUDE) -o $@ $

[mehoggan@hogganz400 Core]$ make
mkdir -p ./libs
mkdir -p ./obj/symb_obj
make -f ./Graphic/SymbolXLib/Makefile
make[1]: Entering directory `/home/mehoggan/arcgis-new/GraphicsCore_Dev/Runtime/Core'
make[1]: *** No rule to make target `obj/symb_obj/CartoCursor.o', needed by `libSymbolXLib.a'.  Stop.
make[1]: Leaving directory `/home/mehoggan/arcgis-new/GraphicsCore_Dev/Runtime/Core'
make: *** [build_symbol_x_lib] Error 2
[mehoggan@hogganz400 Core]$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-redhat-linux-gnu
[mehoggan@hogganz400 Core]$ uname -a
Linux hogganz400.esri.com 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[mehoggan@hogganz400 Core]$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.0 (Santiago)
[mehoggan@hogganz400 Core]$ 
1
  • Have you tried removing the ./ prefix on SYMB_OBJ_DIR? Commented Dec 29, 2011 at 21:14

2 Answers 2

2

It looks a lot like the INT_DIR and $? variables used is out of place. I'd expect this:

$(SYMB_OBJ_DIR)/%.o : %.cpp
    $(CXX) -c $(CC_FLAGS) $(SYMB_X_INCLUDE) -o $@ $<

You'll want to update the ar rules for libSymbolXLib.a to be something else than just rm too :)

The following example worked just fine on my system:

SRC = \
      CartoCursor.cpp \
      CartoOperatorFactory.cpp \
      CurveHelper.cpp \
      $(NULL)

CXX = g++
CC_FLAGS = -fPIC -Wall
SYMB_OBJ_DIR = ./obj/symb_obj
SYMB_X_INCLUDE = -I../../../MYLIBS
SYMB_X_OBJS = $(SRC:%.cpp=$(SYMB_OBJ_DIR)/%.o)

all : libSymbolXLib.a

libSymbolXLib.a : $(SYMB_X_OBJS)
    ar rcs $@ $^

$(SYMB_OBJ_DIR)/%.o : %.cpp
    $(CXX) -c $(CC_FLAGS) $(SYMB_X_INCLUDE) -o $@ $<

Demo:

$ touch CartoCursor.cpp CartoOperatorFactory.cpp CurveHelper.cpp
$ mkdir -pv obj/symb_obj
$ make

g++ -c -fPIC -Wall -I../../../MYLIBS -o obj/symb_obj/CartoCursor.o CartoCursor.cpp
g++ -c -fPIC -Wall -I../../../MYLIBS -o obj/symb_obj/CartoOperatorFactory.o CartoOperatorFactory.cpp
g++ -c -fPIC -Wall -I../../../MYLIBS -o obj/symb_obj/CurveHelper.o CurveHelper.cpp
ar rcs libSymbolXLib.a obj/symb_obj/CartoCursor.o obj/symb_obj/CartoOperatorFactory.o obj/symb_obj/CurveHelper.o

$ file libSymbolXLib.a

libSymbolXLib.a: current ar archive
Sign up to request clarification or add additional context in comments.

1 Comment

added full demo, fixing a typo
1

Make sure that CartoCursor.cpp exists in the directory where you run Make.

Also accordingly to Paul's Rules of Makefiles you should modify recipe of $(SYMB_OBJ_DIR)/%.o : %.cpp to update the file with exact name of the target, that is:

$(SYMB_OBJ_DIR)/%.o : %.cpp
    $(CXX) -c $(CC_FLAGS) $(SYMB_X_INCLUDE) -o $@ $^

UPD.

The same applies to recipe for libSymbolXLib.a, it must update the target file. You can insert a touch $@ stub for debugging, or as @sehe has mentioned add a proper recipe:

libSymbolXLib.a : $(SYMB_X_OBJS)
    ar rcs $@ $^

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.