Results 1 to 4 of 4
I am trying to create a simple Makefile for a collection of code-files I have, but I get this error every time I compile:
/bin/sh: syntax error at line 1: ...
- 08-12-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 2
Need some help with a simple Makefile...
I am trying to create a simple Makefile for a collection of code-files I have, but I get this error every time I compile:
/bin/sh: syntax error at line 1: "-c" unexpected
gmake: *** [gentext.o] Error 2
Of course, getting rid of all the -c's in my Makefile doesn't fix anything. Without them, I get:
/bin/sh: syntax error at line 1: `gentext.cpp' unexpected
I'm thinking there must be something really simple I'm missing here. Thanks for any help! Here's all the important bits of my Makefile code:
Code:gmake gentext #------------------------------------------------ # Variables CXX = g++ CXXFLAGS = -Wall -ggdb $(M_DEBUG) RANDOBJS = RandomNumGen.o testRandom.o #------------------------------------------------- # Rules to compile PREFOBJS = gentext.o Prefix2.o RandomNumGen.o gentext: $(PREFOBJS) $(CXX) $(CXXFLAGS) $(PREFOBJS) -o gentext gentext.o: $(CXX) &(CXXFLAGS) -c gentext.cpp Prefix2.o: Prefix2.cpp Prefix2.h $(CXX) &(CXXFLAGS) -c Prefix2.cpp RandomNumGen.o: $(CXX) &(CXXFLAGS) -c RandomNumGen.cpp #------------------------------------------------- Prefix2.o: Prefix2.h testRandom: $(RANDOBJS) $(CXX) $(CXXFLAGS) $(RANDOBJS) -o testRandom $(RANDOBJS): RandomNumGen.h
- 08-12-2009 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
You appear to have used "&" instead of "$" in several places. That will probably fire off the preceding text as a background process, and the subsequent text as another command ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 08-12-2009 #3
yes,as drl said seems like you have used & instead of $ in following lines
Replace all your & into $.gentext.o:
$(CXX) &(CXXFLAGS) -c gentext.cpp
Prefix2.o: Prefix2.cpp Prefix2.h
$(CXX) &(CXXFLAGS) -c Prefix2.cpp
RandomNumGen.o:
$(CXX) &(CXXFLAGS) -c RandomNumGen.cpp- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 08-12-2009 #4Just Joined!
- Join Date
- Aug 2009
- Posts
- 2
oh dear. i feel sufficiently dumb for not realizing such a small but significant error in my code. Thanks for the help!


Reply With Quote