 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Max Guest
|
Posted: Sun Sep 26, 2004 7:31 pm Post subject: Help on makefiles |
|
|
I know this isn't directly related to C++, but thought I'd ask anyway.
I've already read about 10 tutorials on makefiles, still have this
problem and hoping someone here could help me out. I'm creating a
project for my C++ class, it'll be tested on a UNIX system with cxx
compiler. Bellow I've pasted my current makefile for it:
------------------------------------------------------------------------
p1 : main.o DataManager.o EventList.o Event.o NameList.o Name.o
cxx -w0 -std strict_ansi main.o DataManager.o EventList.o Event.o
NameList.o Name.o -o p1
main.o : main.cpp DataManager.h Event.h Name.h
cxx -w0 -std srtict_ansi -c main.cpp
DataManager.o : DataManager.cpp DataManager.h Event.h Name.h EventList.h
cxx -w0 -std srtict_ansi -c DataManager.cpp
EventList.o : EventList.cpp EventList.h Event.h
cxx -w0 -std srtict_ansi -c EventList.cpp
Event.o : Event.cpp Event.h NameList.h
cxx -w0 -std srtict_ansi -c Event.cpp
NameList.o : NameList.cpp NameList.h Name.h
cxx -w0 -std srtict_ansi -c NameList.cpp
Name.o : Name.cpp Name.h
cxx -w0 -std srtict_ansi -c Name.cpp
------------------------------------------------------------------------
(By the way, if the tabs don't stay, just know that they are there at
every cxx line). So the way this works is, Name is no dependant on
anything, NameList is dependant on Name, Event is dependant on NameList,
and so on towards the top.
The problem that I'm having is that when I run make, I get an error
message saying that it doesn't know how to make Name.h. Basically it
takes the last dependency of the second label and gives me that error
message. This seems a little strange since I'm listing Name.h as a
dependency, not trying to make it. Any insight on what I'm doing wrong?
Never used makefiles before, so I'm sure there has to be something...
Thanks for any help.
|
|
| Back to top |
|
 |
Jacek Dziedzic Guest
|
Posted: Sun Sep 26, 2004 8:18 pm Post subject: Re: [OT] Help on makefiles |
|
|
This is off-topic in this NG. However you might try to remove
all occurrences of .h files in your makefile, this should fix it.
HTH,
- J.
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Sun Sep 26, 2004 9:26 pm Post subject: Re: [OT] Help on makefiles |
|
|
Jacek Dziedzic wrote:
| Quote: |
This is off-topic in this NG. However you might try to remove
all occurrences of .h files in your makefile, this should fix it.
HTH,
- J.
|
Thanks for that suggestion, but I already tried it right after posting
here. If I remove all .h files then it just complains about being unable
to make main.cpp.
Also, what newsgroup is best for this type of question?
|
|
| Back to top |
|
 |
Dan Mills Guest
|
Posted: Sun Sep 26, 2004 11:26 pm Post subject: Re: [OT] Help on makefiles |
|
|
Max wrote:
| Quote: |
Thanks for that suggestion, but I already tried it right after posting
here. If I remove all .h files then it just complains about being unable
to make main.cpp.
|
Daft thought, but you do know that unix is case sensitive right?
Also if cxx is anything like g++ then you need to specify the object name
when compiling or it will default to a.out which is probably not what you
want.
This this would be modified by adding a -oDataManager.o to the end of the
line starting <tab>cxx....
DataManager.o : DataManager.cpp DataManager.h Event.h Name.h EventList.h
cxx -w0 -std srtict_ansi -c DataManager.cpp
This is not your immediate problem but I thought it was worth mentioning.
Make bitching about not knowing how to make something that you have listed
as a dependency is usaually down to a typo in the name of the file.....
| Quote: | Also, what newsgroup is best for this type of question?
|
I would try comp.unix.programmer.
Regards, Dan.
--
** The email address *IS* valid, do NOT remove the spamblock
And on the evening of the first day the lord said...........
..... LX 1, GO!; and there was light.
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Sun Sep 26, 2004 11:46 pm Post subject: Re: Help on makefiles |
|
|
Max wrote:
[snip]
| Quote: | The problem that I'm having is that, when I run make,
I get an error message saying that it doesn't know how to make Name.h.
|
make can't find Name.h
You misspelled it
or put it somewhere other than the directory where you invoked make.
| Quote: | Basically, it takes the last dependency of the second label
and gives me that error message.
This seems a little strange
since I'm listing Name.h as a dependency, not trying to make it.
|
make can't find Name.h so it looks for a rule to make it.
| Quote: | Any insight on what I'm doing wrong?
I never used makefiles before
so I'm sure there has to be something...
|
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Mon Sep 27, 2004 12:23 am Post subject: Re: Help on makefiles |
|
|
E. Robert Tisdale wrote:
| Quote: | Max wrote:
[snip]
The problem that I'm having is that, when I run make, I get an error
message saying that it doesn't know how to make Name.h.
make can't find Name.h
You misspelled it
or put it somewhere other than the directory where you invoked make.
Basically, it takes the last dependency of the second label
and gives me that error message.
This seems a little strange since I'm listing Name.h as a dependency,
not trying to make it.
make can't find Name.h so it looks for a rule to make it.
Any insight on what I'm doing wrong?
I never used makefiles before
so I'm sure there has to be something...
|
Here's the way my directory looks. As you can see all files are there
along with the makefile. I've already checked the spelling many times.
Still no luck :(
% ls
DataManager.cpp EventList.cpp Name.o main.cpp
DataManager.h EventList.h NameList.cpp main.o
DataManager.o EventList.o NameList.h my.output
Event.cpp Makefile NameList.o primary.input
Event.h Name.cpp a.out primary.output
Event.o Name.h cxx_repository
% make
.. Stop.n't know how to make Name.h
%
Btw, the .o files and a.out is what I got from just building the whole
thing manually. Make didn't generate those.
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Mon Sep 27, 2004 12:26 am Post subject: Re: [OT] Help on makefiles |
|
|
Dan Mills wrote:
| Quote: | Max wrote:
Thanks for that suggestion, but I already tried it right after posting
here. If I remove all .h files then it just complains about being unable
to make main.cpp.
Daft thought, but you do know that unix is case sensitive right?
Also if cxx is anything like g++ then you need to specify the object name
when compiling or it will default to a.out which is probably not what you
want.
This this would be modified by adding a -oDataManager.o to the end of the
line starting <tab>cxx....
DataManager.o : DataManager.cpp DataManager.h Event.h Name.h EventList.h
cxx -w0 -std srtict_ansi -c DataManager.cpp
This is not your immediate problem but I thought it was worth mentioning.
Make bitching about not knowing how to make something that you have listed
as a dependency is usaually down to a typo in the name of the file.....
Also, what newsgroup is best for this type of question?
I would try comp.unix.programmer.
Regards, Dan.
|
All right, thanks. I'll try it there as well. But in the mean time, see
my reply to Robert. Don't think it's a typo and it's not due to letter
case either. Already checked all of that. As for a.out, the way I have
it right now is to build p1, but honestly if it gave me a.out I would be
very happy just as well. Just want it to give me something.
|
|
| Back to top |
|
 |
David Lindauer Guest
|
Posted: Mon Sep 27, 2004 12:41 am Post subject: Re: Help on makefiles |
|
|
I don't know about the first CXX line... is there really a line feed at the
end or is it just line wrapping because
you put it in a post? If it is the former that may be confusing make... I
don't know about unix make but the
make programs I have seen need a '' if you are going to do line
continuation on another line.
David
Max wrote:
| Quote: | E. Robert Tisdale wrote:
Max wrote:
[snip]
The problem that I'm having is that, when I run make, I get an error
message saying that it doesn't know how to make Name.h.
make can't find Name.h
You misspelled it
or put it somewhere other than the directory where you invoked make.
Basically, it takes the last dependency of the second label
and gives me that error message.
This seems a little strange since I'm listing Name.h as a dependency,
not trying to make it.
make can't find Name.h so it looks for a rule to make it.
Any insight on what I'm doing wrong?
I never used makefiles before
so I'm sure there has to be something...
Here's the way my directory looks. As you can see all files are there
along with the makefile. I've already checked the spelling many times.
Still no luck :(
% ls
DataManager.cpp EventList.cpp Name.o main.cpp
DataManager.h EventList.h NameList.cpp main.o
DataManager.o EventList.o NameList.h my.output
Event.cpp Makefile NameList.o primary.input
Event.h Name.cpp a.out primary.output
Event.o Name.h cxx_repository
% make
. Stop.n't know how to make Name.h
%
Btw, the .o files and a.out is what I got from just building the whole
thing manually. Make didn't generate those.
|
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Mon Sep 27, 2004 12:46 am Post subject: Re: Help on makefiles |
|
|
David Lindauer wrote:
| Quote: | I don't know about the first CXX line... is there really a line feed at the
end or is it just line wrapping because
you put it in a post? If it is the former that may be confusing make... I
don't know about unix make but the
make programs I have seen need a '' if you are going to do line
continuation on another line.
David
|
No line feed there. Might just be your screen resolution. This does look
more like make doesn't recognize that Name.h is a file, but I have no
idea what I can do about it... I even tried specifying complete paths to
those files, not relative ones. Same story.
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Mon Sep 27, 2004 12:55 am Post subject: Re: Help on makefiles |
|
|
Max wrote:
| Quote: | Here's the way my directory looks.
As you can see all files are there along with the makefile.
I've already checked the spelling many times.
Still no luck :(
% ls
DataManager.cpp EventList.cpp Name.o main.cpp
DataManager.h EventList.h NameList.cpp main.o
DataManager.o EventList.o NameList.h my.output
Event.cpp Makefile NameList.o primary.input
Event.h Name.cpp a.out primary.output
Event.o Name.h cxx_repository
% make
. Stop.n't know how to make Name.h
%
Btw, the .o files and a.out is what I got from just building the whole
thing manually. Make didn't generate those.
ls -w 70
DataManager.cpp Event.h main.cpp Name.h |
DataManager.h EventList.cpp Makefile NameList.cpp
Event.cpp EventList.h Name.cpp NameList.h
| Quote: | expand Makefile
p1: main.o DataManager.o EventList.o Event.o |
NameList.o Name.o
g++ -Wall -ansi -pedantic
main.o DataManager.o EventList.o Event.o NameList.o Name.o -o
p1
main.o: main.cpp DataManager.h Event.h Name.h
g++ -Wall -ansi -pedantic -c main.cpp
DataManager.o: DataManager.cpp DataManager.h Event.h Name.h
EventList.h
g++ -Wall -ansi -pedantic -c DataManager.cpp
EventList.o: EventList.cpp EventList.h Event.h
g++ -Wall -ansi -pedantic -c EventList.cpp
Event.o: Event.cpp Event.h NameList.h
g++ -Wall -ansi -pedantic -c Event.cpp
NameList.o: NameList.cpp NameList.h Name.h
g++ -Wall -ansi -pedantic -c NameList.cpp
Name.o: Name.cpp Name.h
g++ -Wall -ansi -pedantic -c Name.cpp
clean:
rm -f p1 *.o
| Quote: | make
g++ -Wall -ansi -pedantic -c main.cpp |
g++ -Wall -ansi -pedantic -c DataManager.cpp
g++ -Wall -ansi -pedantic -c EventList.cpp
g++ -Wall -ansi -pedantic -c Event.cpp
g++ -Wall -ansi -pedantic -c NameList.cpp
g++ -Wall -ansi -pedantic -c Name.cpp
g++ -Wall -ansi -pedantic
main.o DataManager.o EventList.o Event.o NameList.o Name.o -o p1
| Quote: | ls -w 60
DataManager.cpp EventList.cpp main.o NameList.h |
DataManager.h EventList.h Makefile NameList.o
DataManager.o EventList.o Name.cpp Name.o
Event.cpp Event.o Name.h p1
Event.h main.cpp NameList.cpp
It seems to work just fine for me.
Did you notice that you misspelled strict_ansi
in every target after the first?
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Mon Sep 27, 2004 1:33 am Post subject: Re: Help on makefiles |
|
|
Well guys, after a long day of working on this thing I finally got it to
work... Apparently, until I put spaces at the end of every line, it
couldn't find a thing. Oh, and it also wouldn't run the last line of the
file until I put an extra line feed. Right about now I would like to
kill the person who came up with this idea, but at least I'm happy that
it works now.
Thanks for all your help
|
|
| Back to top |
|
 |
Max Guest
|
Posted: Mon Sep 27, 2004 1:59 am Post subject: Re: Help on makefiles |
|
|
E. Robert Tisdale wrote:
| Quote: |
It seems to work just fine for me.
Did you notice that you misspelled strict_ansi
in every target after the first?
|
Yea, those I fixed. See my reply to the original post. It was all
because I didn't have any spaces at the end of each line, and also
because I didn't have an extra line at the end of the file.
|
|
| Back to top |
|
 |
Phlip Guest
|
Posted: Mon Sep 27, 2004 3:31 am Post subject: Re: [OT] Help on makefiles |
|
|
Max wrote:
| Quote: | Still no luck :(
% ls
^ |
You need to configure your shell - probably by setting PS1 - to reflect your
current folder. That makes BASHing (or using whatever SHell you use) a
little easier.
(BTW you have probably been warned this question is off topic. Hence we can
answer any part of it we feel like ;-)
--
Phlip
http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|