gpt4 book ai didi

c++ - Makefile 因 C++ 编译而失败

转载 作者:太空宇宙 更新时间:2023-11-04 06:27:51 25 4
gpt4 key购买 nike

<分区>

我有这个 Makefile:

TARGET  =   foobar
CXX = g++
CXXFLAGS = -Wall -I./inc/
LINKER = $(CXX) -o
LFLAGS = -I./inc/

SRCDIR = src
INCDIR = inc
OBJDIR = obj
BINDIR = bin

SOURCES := $(wildcard &(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(INCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
rm = rm -f

$(info SOURCES [${SOURCES}])
$(info INCLUDES [${SOURCES}])
$(info OBJECTS [${OBJECTS}])

$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $@ $(LFLAGS) $(OBJECTS)
@echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@$(CXX) $(CXXFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully"

.PHONY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"

.PHONE: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Exacutable removed!"

我的文件夹结构是:

src/somesources.cpp
inc/somesources.h
obj/
bin/
Makefile

这个 makefile 可以完美地处理 c 文件,但我在处理 c++ 时遇到了问题。有人能说出 c 和 c++ 之间的区别以及我哪里错了吗?我得到的输出消息是:

SOURCES []
INCLUDES []
OBJECTS []
g++: fatal error: no input files
compilation terminated.

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com