LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2005, 04:52 AM   #1
ivanbbq
LQ Newbie
 
Registered: Mar 2005
Posts: 4

Rep: Reputation: 0
probelm when writing a makefile


here is what my makefile looks like

-------------------------------------------------------------------
CC=gcc
all : Project BlkLanApp.o zcstrd.o AlkLanAux.o Data.o BlkTriAux.o LanTriAux.o MatCompute.o BlkTri.o LanTri.o LapackWrap.o
Project : BlkLanApp.o zcstrd.o BlkLanAux.o Data.o BlkTriAux.o LanTriAux.o MatCompute.o BlkTri.o LanTri.o LapackWrap.o
$(CC) -o Project BlkLanApp.o zcstrd.o BlkLanAux.o Data.o BlkTriAux.o LanTriAux.o MatCompute.o BlkTri.o LanTri.o LapackWrap.o lapack_SUN4SOL2.a blas_SUN4SOL2.a libF77.a libI77.a -lm -lc
BlkLanApp.o : BlkLanApp.c zcstrd.h
$(CC) -c BlkLanApp.c
zcstrd.o : Blklan.h zcstrd.c
$(CC) -c zcstrd.c
BlkLanAux.o : Blklan.h BlkLanAux.c
$(CC) -c BlkLanAux.c
Data.o : Blklan.h Data.c
$(CC) -c Data.c
BlkTriAux.o : Blklan.h BlkTriAux.c
$(CC) -c BlkTriAux.c
LanTriAux.o : BlkLan.h LanTriAux.c
$(CC) -c LanTriAux.c
MatCompute.o : computing.h MatCompute.c
$(CC) -c MatCompute.c
BlkTri.o : Blklan.h BlkTri.c
$(CC) -c BlkTri.c
LanTri.o : Blklan.h LanTri.c
$(CC) -c LanTri.c
LapackWrap.o : f2c.h blaswrap.h fblaswr.h computing.h LapackWrap.c
$(CC) -c LapackWrap.c
clean :
rm BlkLanApp.o zcstrd.o BlkLanAux.o Data.o BlkTriAux.o LanTriAux.o MatCompute.o BlkTri.o LanTri.o LapackWrap.o
---------------------------------------------------------------
and i do have tab at the beginning of the commands.

when i try to run it by make, the following error occur.
---------------------------------------------------------------
[makyk@birkhoff trunk] make
'ake: Fatal error: Don't know how to make target `zcstrd.h
---------------------------------------------------------------

and the same erro when i try to only compile the BlkLanApp.o
---------------------------------------------------------------
[makyk@birkhoff trunk] make BlkLanApp.o
'ake: Fatal error: Don't know how to make target `zcstrd.h
---------------------------------------------------------------

I don't understand why this happened.
the zcstrd.h is a dependency of BlkLanApp.o
why it says Don't know how to make target?

it happens for all other object files, that the system Don't know how to make it's dependency.

thx for helping...
 
Old 03-13-2005, 10:23 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
my best guess is that you don't have zcstrd.h in the folder--if it was, make (probably) wouldn't complain.

btw, make* knows how to make .o files from .c files, so you can actually cut out all the $(CC) -c %.c lines; look for `implicit rules' in http://www.gnu.org/software/make/man...ono/make.html; also, it considered poor style to duplicate information;

objects = BlkLanApp.o zcstrd.o BlkLanAux.o Data.o BlkTriAux.o LanTriAux.o MatCompute.o BlkTri.o LanTri.o LapackWrap
all: Project $(objects)
Project: $(objects)
\t$(CC) -o $(objects) $(dot_a_files) -lm ...
...
clean:
\trm $(objects)
---
in that way, you only have to update the list of .o-files in one place: faster and less error-prone.

* I'm assuming you use GNU make.
 
Old 03-13-2005, 10:50 AM   #3
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
Remove all references to header files in your makefile. Just keep them where the compiler can find them (usually in the same directory as your other source files).
 
Old 03-13-2005, 10:56 AM   #4
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Hivemind: I'm sorry, isn't the idea of make to express inter-file dependencies? And isn't that purpose defeated when you remove some of the actual relations from the Makefile?

Oh, and a suggestion for both of you: go to "User CP" -> "distro" and enter your distributions; if you don't want to, state so.

sorry for being an arrogant @$$hole

Jonas
 
Old 03-13-2005, 11:09 AM   #5
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
I don't really know what you are talking about Jonas. The compiler will issue an error if it can't find a particular header file and what header files should be included is specified in the source not in the parameters passed to the compiler or the linker. And in the example you showed yourself there is no mention of header files.
 
Old 03-13-2005, 11:17 AM   #6
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
We might be talking past each other.

>> The compiler will issue an error if it can't find a particular header file [..]
correct.

>> and what header files should be included is specified in the source not in the parameters passed to the compiler or the linker.
correct.
Well, you could use gcc -Ifoo.h, but that's just disgusting and not the case here.

>> And in the example you showed yourself there is no mention of header files.
correct. However, that makefile fragment is meant to illustrate something different: how refactoring helps readability and reliability;

quickly scanning the makefile, doesn't look as if OP tries to compile any headers, so no problem there. They're not even given as args to $(CC). However, they are included in the dependency sections:

foo.o: foo.c _foo.h_ <-- it's okay for it to be here.
[tab]$(CC) ...

does that make it clearer?

kind regards,

Jonas
 
Old 03-13-2005, 04:13 PM   #7
ivanbbq
LQ Newbie
 
Registered: Mar 2005
Posts: 4

Original Poster
Rep: Reputation: 0
But the fact is, all the header files and .c files are in the folder already.
the BlkLanApp.c includes the zcstrd.h, and i could compile the BlkLanApp.c to BlkLanApp.o by typing the command gcc -c BlkLanApp.c by myself.

I know about the implicit rules, I just tried both of the ways, see whether i made mistake in any of them. But the result is, none of them works, so using implicit rules doesn't related to this error.

I tried to remove all the dependencies before.
but it turns out the error message will become
---------------------------------------------------
'ake: Fatal error: Don't know how to make target `
----------------------------------------------------

please, anybody knows the reason, please tell me.....
 
Old 03-13-2005, 04:22 PM   #8
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
what version of make are you using?
 
Old 03-13-2005, 04:28 PM   #9
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
can you complile

zcstrd.c

manually without make


can it be compiled by just typing in gcc -c zcstrd.c ?

if not then i would say thats the issue.


Can this program be compiled without make if so then whats the error gcc is giving you.


otherwise just posting the make error is totaly useless to debug. I dont particulary think this is a make problem but more of a source or libary issue.

remeber that #include can be nested.
 
Old 03-14-2005, 01:36 AM   #10
ivanbbq
LQ Newbie
 
Registered: Mar 2005
Posts: 4

Original Poster
Rep: Reputation: 0
i don't know what the version of make is, i am using the computer of my school.

yes i can compile every .c file with the command inside the makefile. If i type them one by one by myself.
Actually i have successfully compiled the program before i write this makefile.
But i don't know why when all the commands are placed in the makefile, it doesn't work.

All the header files, .c files are in the same folder.
And i can compile all the .c files to object file. and link the libraries to them manually.
with the commands
gcc -c BlkLanApp.c
gcc -c zcstrd.c
.
.
.
gcc -o Project BlkLanApp.o ......... libI77.a -lm -lc
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to modify makefile.in or makefile.am QiangWan Linux - Newbie 1 05-17-2005 12:07 PM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 04:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 01:23 PM
Internet Probelm Fonke0412 Linux - Networking 1 03-07-2004 12:26 PM
cd writing software which supports multisession writing jayakrishnan Linux - General 3 03-24-2003 06:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration