【发布时间】:2016-06-02 20:58:40
【问题描述】:
我正在尝试运行此 makefile,但遇到了问题。让我告诉我
"No rule to make target 'UDP_Server.o', needed by 'SendRawData',
既然我已经给了它文件的工作目录,那么 %.o 文件的规则不应该正常工作吗?我在 /thing/asset/src 目录中启动 make,我不在乎它把 o 文件或程序放在哪里,只要我可以访问它们。这是我的生成文件:
CC = g++
INC += -I/home/pi/thing/
INC += -I/home/pi/thing/Asset/src/
INC += -I/home/pi/thing/Server/src/
INC += -I/home/pi/thing/Shared/NetworkInterface/src/
INC += -I/home/pi/mercuryapi/c/src/
LIB = /home/pi/mercury/c/src/api/
CFLAGS = -std=c++11 -Wno-write-strings
LDFLAGS = -L$(LIB) -static -l libmercuryapi
SOURCES += UDP_Client.cpp
SOURCES += UDP_Server.cpp
SOURCES += rawData.cpp
SOURCES += packetMethods.cpp
SOURCES += parseData.cpp
SOURCES += SendRawData.cpp
OBJECTS = $(SOURCES:.cpp=.o)
DEPS = UDP_Client.h
DEPS += UDP_Server.h
DEPS += packet.h
DEPS += rawData.h
DEPS += packetMethods.h
DEPS += parseData.h
DEPS += tm_reader.h
default: SendRawData
%.o: %.cpp $(SOURCES) $(DEPS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
SendRawData: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(INC) $< -o SendRawData
client: cmain.cpp UDP_Client.cpp
$(CC) $(CFLAGS) cmain.cpp UDP_Client.cpp -o client
.cpp.o:
$(CC) $(CFLAGS) $(INC) -c $< -o $@
.PHONY: clean
clean:
rm *.o
如果有帮助的话,这里是可视化的目录结构:
/home/pi/thing/
├── Asset
│ ├── README.txt
│ └── src
│ ├── makefile
│ ├── README.txt
│ ├── SendRawData.cpp
│ ├── UDP_Client.cpp
│ └── UDP_Client.h
├── Server
│ └── src
│ ├── README.txt
│ ├── server
│ ├── UDP_Server.cpp
│ ├── UDP_Server.h
│ └── UDP_Server.o
└── Shared
├── NetworkInterface
│ ├── README.txt
│ └── src
│ ├── header.h
│ ├── packet.h
│ ├── packetMethods.cpp
│ ├── packetMethods.h
│ ├── parseData.cpp
│ ├── parseData.h
│ ├── rawData.cpp
│ ├── rawData.h
│ └── testing.cpp
└── README.txt
【问题讨论】:
-
你给了一个makefile,但是你的树说你有多个,是哪一个?
-
你在哪里执行 Make?你希望它把二进制文件放在哪里(例如
UDP_Client.o和SendRawData)? -
改变了,好点。
标签: c++ c compilation compiler-errors makefile