我在编译一些下载的文件(用于学术目的)时遇到了一些困难。我运行了以下命令:
cd tmp/Detri_2.6.a/detri
然后 make detri_new CC=gcc 从提取到 /tmp 的相关文件和文件夹构建库。
输出如下:
tmp/Detri_2.6.a/detri$ make detri_new CC=gcc
g++ Makefile.cpp -o Makefile
Makefile.cpp:16:25: error: expected unqualified-id before ‘-’ token
Makefile.cpp:16:38: error: expected unqualified-id before ‘-’ token
Makefile.cpp:17:1: error: ‘LIBS’ does not name a type
Makefile.cpp:20:1: error: ‘MODULES’ does not name a type
[..]
Makefile.cpp:65:73: error: expected unqualified-id before ‘-’ token
Makefile.cpp:68:1: error: expected unqualified-id before ‘.’ token
Makefile.cpp:68:19: error: ‘$’ does not name a type
Makefile.cpp:68:60: error: expected unqualified-id before ‘-’ token
Makefile.cpp:71:10: error: ‘$’ does not name a type
Makefile.cpp:71:20: error: expected unqualified-id before ‘-’ token
Makefile.cpp:71:31: error: expected unqualified-id before ‘--’ token
Makefile.cpp:71:43: error: ‘$’ does not name a type
make: *** [Makefile] Error 1
>
我还没有编写 makefile.cpp(请记住这是我使用 ubuntu 并做此类事情的第一周),但以前,编译器会尝试在 makefile.tmp 中构建并查找错误,而不是在 .cpp 文件中。现在,正如输出所示,它不会超出尝试读取 .cpp 文件的程度。
我有点迷路了......
谢谢
更新:我已尝试以下评论中建议的操作,即运行:make -k TMPMK=Makefile.tmp detri_new CC=gcc
但我仍然有相同的(窗口充满的)输出错误,以及一些新的错误。
如果这有帮助的话,代码是从以下获取的网站
编辑:缩短错误输出部分并更清楚地解释问题。
以下是 makefile:
/* detri/Makefile.cpp --- C pre-processor Makefile for detri. */
/* USAGE: cpp -P ${CPPMK} > ${TMPMK}; make -k TMPMK=${TMPMK} -f ${TMPMK} ... */
/* Targets. (CHANGE THIS ACCORDING TO YOUR NEEDS!) */
DEST= ../bin
LIB= ../lib
INCLUDE= ../include
/* Paramters: DEPEND, SHELL, CC, CPP, CPPMK, TMPMK, COPT. */
/* System specifics: CCFLAGS, AR, RANLIB, MALLOC. */
#include "Makefile.sys"
/* Other libraries. */
INCLS= -I${INCLUDE}
LIBRARIES= -l_sos${DBX} -l_lia${DBX} -l_basic${DBX}
LIBS= -L${LIB}
/* Source and object files. */
MODULES= detri.c delaunay.c flip.c prep.c \
dt.c print_dt.c search.c trist.c peel.c
H_FILES= detri.h dt.h trist.h
OBJECTS= ${MODULES:.c=.o}
/* Interface. */
normal: detri; @echo "Detri ready."
debug: ; ${MAKE} -k -f ${TMPMK} detri COPT="-D__DEBUG__" DBX=-g
remove: ; rm -f ${OBJECTS}
all: normal;
/* BEGIN Meta Interface: make detri_new */
/* Note: This is here so that we can package Detri stand-alone,
without the alpha shape software and it's top-level Makefile. */
BASIC= ../basic
LIA= ../lia
SOS= ../sos
DETRI= ./
HD=echo "\n\n*** X ***\n"
MK= ${MAKE} -k CC="${CC}" CPP="${CPP}" COPT="${COPT}"
detri_new:; ${MK} check soslibs_ detri_
detri_debug:; ${MK} check soslibs_d detri_d
detri_all:; ${MK} check soslibs_d soslibs_ detri_
soslibs_: basic_ lia_ sos_
detri_:; @/bin/csh -cf '${HD:X=Detri}; cd ${DETRI}; ${MK} new'
sos_:; @/bin/csh -cf '${HD:X=SoS}; cd ${SOS}; ${MK} new'
lia_:; @/bin/csh -cf '${HD:X=Lia}; cd ${LIA}; ${MK} new'
basic_:; @/bin/csh -cf '${HD:X=Basic}; cd ${BASIC}; ${MK} new'
soslibs_d: basic_d lia_d sos_d
detri_d:; @/bin/csh -cf '${HD:X=Detri}; cd ${DETRI}; ${MK} clear debug'
sos_d:; @/bin/csh -cf '${HD:X=SoS}; cd ${SOS}; ${MK} clear debug'
lia_d:; @/bin/csh -cf '${HD:X=Lia}; cd ${LIA}; ${MK} clear debug'
basic_d:; @/bin/csh -cf '${HD:X=Basic}; cd ${BASIC}; ${MK} clear debug'
check:; @/bin/csh -cf ' \
echo Checking for target dirs; \
if (! -e ${DEST}) mkdir ${DEST}; \
if (! -e ${LIB}) mkdir ${LIB}; \
if (! -e ${INCLUDE}) mkdir ${INCLUDE} \
'
/* Internal rules. */
detri: ${OBJECTS}; ${CC} ${CCFLAGS} ${DBX} ${COPT} ${OBJECTS} \
-o ${DEST}/detri ${LIBS} ${LIBRARIES} ${MALLOC} -lm;
/* Generic rule to compile source files. */
.c.o: ${H_FILES}; ${CC} ${CCFLAGS} ${DBX} ${COPT} ${INCLS} -c $*.c -o $*.o
/* To compute dependencies with "make depend" ... */
depend:; ${DEPEND} -f${TMPMK} -- ${INCLS} ${MODULES}
答案1
据我所知,这个 Makefile.cpp 用于使用 C 预处理器生成 Makfeile。如你所见,在 Makefile.cpp 中有一行:
/* USAGE: cpp -P ${CPPMK} > ${TMPMK}; make -k TMPMK=${TMPMK} -f ${TMPMK} ... */
这意味着您应该运行 C 预处理器 (cpp) 来获取真正的 Makefile。通过键入,您将基于cpp -P Makefile.cpp > Makefile.tmp
生成。根据此使用注释,您应该将生成的文件作为变量值传递给 make,例如。希望这对您有所帮助。Makefile.tmp
Makefile.cpp
Makefile.tmp
TMPMK
make -k TMPMK=Makefile.tmp detri_new CC=gcc