Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
I have the following makefile
TARGET := test.so
DEFINES := 
CC := g++
CFLAGS := -Wall -O3 -c -fpic -I$(INCLUDES)
LDFLAGS := -lrt -ldl -lpthread -s -shared -fpic
SRCS := ./main.cpp \
../../src/test.cpp
INCLUDES =    -I../../inc

###########################
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
all: $(TARGET)
$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $^
%.o: %.cpp
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $<
clean:
	rm -rf $(TARGET) *.o ./.depend
depend: .depend
.depend: $(SRCS)
	rm -rf ./.depend
	$(CC) $(CFLAGS) $(DEFINES) -MM $^>>./.depend
include .depend
.PHONY: all clean

after running make I got the below error
g++: error: ../../src/test.o: No such file or directory


What I have tried:

it is right, My test.o file is built beside the main.o
when I ran the following command separately in terminal my .so was built successfuly
g++ -lrt -ldl -lpthread -s -shared -fpic -o test.so main.o test.o 

how can my makefile implement this behavior?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900