projectroot/
|
+------------------------------+----------------------------+
| | |
include/ libs/ helloworld/
| | |
shader_utils.h shader_utils.c triangle.c
项目根目录下有三个目录。 helloworld目录包含triangle.c,它取决于shader_utils.h(在projectroot / include下),其定义在projectroot / libs.and下面,这是我的make文件。什么是错的。
#!bin/sh
CC=gcc
LDLIBS=-lglut -lGLEW -lGL
ROOT=/media/programming/experiments/projectroot
VPATH=../libs:../include
INC=-I$(ROOT)/include
all: triangle
triangle: triangle.o shader_utils.o
cc -c $(CFLAGS) $< -o $@ $(INC)
shader_utils.o: shader_utils.h
cc -c $(CFLAGS) $< -o $@ $(INC)
clean:
rm -f *.o triangle
.PHONY: all clean
试图制作时。它告诉这个
cc -c ../include/shader_utils.h -o shader_utils.o -I/media/programming/experiments/projectroot/include
cc -c triangle.o -o triangle -I/media/programming/experiments/projectroot/include
cc: warning: triangle.o: linker input file unused because linking not done
答案 0 :(得分:0)
这条规则毫无意义:
triangle: triangle.o shader_utils.o
cc -c $(CFLAGS) $< -o $@ $(INC)
您告诉Make构造可执行文件,但要求它使用-c
。只需删除所有规则,让默认设置为您服务。重写Makefile:
CC=gcc
LDLIBS=-lglut -lGLEW -lGL
ROOT=/media/programming/experiments/projectroot
VPATH=../libs:../include
CFLAGS=-I$(ROOT)/include
all: triangle
triangle: triangle.o shader_utils.o
shader_utils.o: shader_utils.h
clean:
rm -f *.o triangle
.PHONY: all clean