makefile出错,从src目录中的所有内容构建

时间:2016-08-26 23:56:30

标签: c++ makefile

我一直在尝试复制我在网上找到的makefile。我目前陷入以下错误:

MyComputer:folderName userName$ make
make: bin/kernel: No such file or directory
make: *** [bin/kernel] Error 1

makefile源代码如下:

### Typing 'make' will create the executable file.
CC = gcc
CFLAGS  = -g -Wall
LDFLAGS = 
LIBS = -lstdc++

TARGET = kernel
SRCDIR = src
OBJDIR = obj
BINDIR = bin
#TARGETDIR = $(BINDIR)/$(TARGET)

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

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

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cc
    @$(CC) $(CFLAGS) -c $< -o $@
    @echo "Compiled "$<" successfully!"

#$(CC) $(CFLAGS) $(LFLAGS) -o $(MAIN) $(OBJS) $(LIBS) $@

#make clean removed from this code, unnecessary

我尝试过的事情:

  • $(BINDER)/$(TARGET):更改为$(BINDER)make: bin: No such file or directory
  • 更改文件夹权限并以sudo身份运行(无效)
  • 制作bin / kernel文件夹(Permission Denied w / sudo和chmod 777)
  • 向我们的黑暗领主克苏鲁祈祷(可能不可避免的厄运)

1 个答案:

答案 0 :(得分:2)

您的Makefile假设项目目录的结构如下:

pd.get_dummies(s).astype(np.uint8)

我修改了链接阶段,因为您没有定义a = my_list[0].strip() b = my_list[2].strip()

.
├── bin
├── Makefile
├── obj
└── src
    └── main.cc

运行$(LINKER)现在将创建内核二进制文件。

CC = gcc
CFLAGS  = -g -Wall
LDFLAGS = 
LIBS = -lstdc++

TARGET = kernel
SRCDIR = src
OBJDIR = obj
BINDIR = bin

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

$(BINDIR)/$(TARGET): $(OBJECTS)
    @$(CC) -o $@ $(LFLAGS) $(OBJECTS) $(LIBS)
    @echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cc
    @$(CC) $(CFLAGS) -c $< -o $@
    @echo "Compiled "$<" successfully!"