simbasaurus
September 27th, 2007, 07:17 AM
Hello!
I am trying to write a simple makefile that compiles some C++
sources from ~/testmake/src and places the object files in
~/testmake/obj.
The makefile looks like this:
CC=g++
BASEDIR = ~/testmake
SRC = $(BASEDIR)/src
OBJ = $(BASEDIR)/obj
SOURCES = s1.cpp s2.cpp
OBJECTS = $(SOURCES:.cpp=.o)
vpath %.cpp $(SRC)
vpath %.o $(OBJ)
all: mylib.so $(OBJECTS)
clean:
rm -f $(OBJ)/*.o
$(OBJECTS):\
%.o:%.cpp
$(CC) -c $< -o $(OBJ)/$@
mylib.so: $(OBJECTS)
$(CC) -shared -fPIC -o $@ $^
The output of the make command under Ubuntu 7.04 is
g++ -c s1.cpp -o ~/testmake/obj/s1.o
g++ -c s2.cpp -o ~/testmake/obj/s2.o
g++ -shared -fPIC -o mylib.so s1.o s2.o
g++.real: s1.o: No such file or directory
g++.real: s2.o: No such file or directory
g++.real: no input files
make: *** [mylib.so] Error 1
Can you please tell me what i'm doing wrong?
Shouldn't it find the .o files and create the shared object??
Regards,
Simbasaurus
I am trying to write a simple makefile that compiles some C++
sources from ~/testmake/src and places the object files in
~/testmake/obj.
The makefile looks like this:
CC=g++
BASEDIR = ~/testmake
SRC = $(BASEDIR)/src
OBJ = $(BASEDIR)/obj
SOURCES = s1.cpp s2.cpp
OBJECTS = $(SOURCES:.cpp=.o)
vpath %.cpp $(SRC)
vpath %.o $(OBJ)
all: mylib.so $(OBJECTS)
clean:
rm -f $(OBJ)/*.o
$(OBJECTS):\
%.o:%.cpp
$(CC) -c $< -o $(OBJ)/$@
mylib.so: $(OBJECTS)
$(CC) -shared -fPIC -o $@ $^
The output of the make command under Ubuntu 7.04 is
g++ -c s1.cpp -o ~/testmake/obj/s1.o
g++ -c s2.cpp -o ~/testmake/obj/s2.o
g++ -shared -fPIC -o mylib.so s1.o s2.o
g++.real: s1.o: No such file or directory
g++.real: s2.o: No such file or directory
g++.real: no input files
make: *** [mylib.so] Error 1
Can you please tell me what i'm doing wrong?
Shouldn't it find the .o files and create the shared object??
Regards,
Simbasaurus