Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am having some difficulties compiling some files that I downloaded (for academic purposes). I ran the following command :

cd tmp/Detri_2.6.a/detri

then make detri_new CC=gcc To build a library from the relevant files and folders extracted to /tmp.

The output is as follows:

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


I haven't written the makefile.cpp (please bear in mind this is my first week of using ubuntu and doing this sort of thing) but previously, the compiler would attempt to build and find an error in the makefile.tmp, not in the .cpp file. Now as the output shows, it isn't going past the point of trying to read the .cpp file.

I am a bit lost here...

Thank you

UPDATE: I have tried what was suggested in the comment below, i.e. running : make -k TMPMK=Makefile.tmp detri_new CC=gcc

Yet I still have the same (window full of) output errors, plus some new ones.

If this is of any help, the code was obtained from the following website

EDIT: Shortened error output section and clearer explanation of the problem.

Here is the makefile :

/* detri/Makefile.cpp --- C pre-processor Makefile for detri. */

/* USAGE: cpp -P ${CPPMK} > ${TMPMK}; make -k TMPMK=${TMPMK} -f ${TMPMK} ... */

DEST=    ../bin
LIB=     ../lib
INCLUDE= ../include

/* System specifics: CCFLAGS, AR, RANLIB, MALLOC. */
#include "Makefile.sys"

/* Other libraries. */
LIBRARIES= -l_sos${DBX} -l_lia${DBX} -l_basic${DBX}

/* 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

/* 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

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}
share|improve this question
Change the extension of Makefile.cpp to sth. else, anything not .cpp, .cc, .c or .h would work, as make is trying to compile Makefile.cpp, which is apparently not a C++ file. –  cadadr Nov 22 '12 at 15:28
Hi, I just changed the .cpp to.txt and it appears that the compiler starts. However out of 3 runs now, one of them just exited normally suggesting that eveything went to plan: an executable should be generated in /bin (but it wasn't) and the two other runs I did just crashed my computer deleting the folder in question! Am I doing this wrong ? Thanks –  chems Nov 22 '12 at 16:18
Edit: Misread "to sth. else, anything not .cpp, .cc, .c or .h would work, ". So tried all three .c .cc .h extensions, non of which work. I even tried generating the .tmp file using the cpp -p command and the various extensions (h,c and cc) and running the make -k TMPMK=Makefile.tmp detri_new CC=gcc All in all, I am back to square one. –  chems Nov 22 '12 at 17:04
add comment

1 Answer

as far as I can see, this Makefile.cpp is used to generate Makfeile using C preprocessor. As you can see in Makefile.cpp there is a line:

/* USAGE: cpp -P ${CPPMK} > ${TMPMK}; make -k TMPMK=${TMPMK} -f ${TMPMK} ... */

This means that you should run C preprocessor (cpp) to get real Makefile. By typing cpp -P Makefile.cpp > Makefile.tmp you will generate Makefile.tmp based on Makefile.cpp. According to this usage comment, you should pass this generated Makefile.tmp to make as value for TMPMK variable, e.g. make -k TMPMK=Makefile.tmp detri_new CC=gcc. I hope this helps.

share|improve this answer
Thank you for your reply. I have typed the cpp command, however there was already a makefile.tmp included in the package. (Which was somewhat similar to the .cpp file). Either way, I still get more or less the same error, multiplied by the number of different libraries it is tying to compile (3 I believe). The output is too big for me to add here, but ends with the following new errors 'make[6]: Failed to remake makefile Makefile'. make[6]: Makefile.tmp' is up to date. Makefile.tmp:33: *** missing separator (did you mean TAB instead of 8 spaces?). Stop. make: *** [detri_new] Error 2' –  chems Nov 22 '12 at 14:55
Unfortunately I am not that good with makefiles. But this: Makefile.tmp:33: *** missing separator (did you mean TAB instead of 8 spaces?) looks like that spaces were used instead of TAB characters (there are places in Makefile where only TAB must be used). Check that line 33 in tmp file, and try replacing spaces with TAB. Sorry I couldn't be more helpful. –  Milan Todorovic Nov 22 '12 at 15:08
Yes at first, I never got the errors with the .cpp makefile, only with the supplied .tmp (as opposed to the generated .tmp with your command) So I though of fixing the spaces manually only to find that as I would re run the commands, the .tmp file would update (even when I have it open in gedit) back to its original state. This i though could be fixed by modifying the .cpp file to have the right spaces and tabs, and then everything just went crazy. Even if remove the directory, and restart from scratch, I cant replicate the first set of errors... Edit: Forgot the magic words... Thank you –  chems Nov 22 '12 at 15:27
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.