Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
File hello.h
File main.c
File print.c
File credits.c
(6 points) Write a Makefile that will correctly compile subparts "main.o", "print.o", "credits.o" and both "make helloworld" command and "make" commmand will assemble a program called "helloworld" from those parts. The dependencies should be correct so that if any of the 4 files is updated, the correct pieces will get rebuilt.
(1 point) Your Makefile should be written so that "make clean" command will remove program "helloworld", "*.o" and any other executables which were created.
those are the two i need help with the most. It doesnt seem like i am doing it correctly
2. Relevant commands, code, scripts, algorithms:
make make clean ls
3. The attempts at a solution (include all code and scripts):
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Maybe a short explanation will get you up to speed faster.
The "make" utility is intended for repetitive tasks (like compiling/linking). It works rule-based. In its input file there is a collection of such rules laid out.
Rules consist of target files, source files and actions. When a source file is changed (=has a time stamp younger than the target file) the action is carried out. Usually carrying out the action creates the target file. The big advantage of using a make-file instead of a script with all the compiler/linker commands is that "make" will skip all the files which are already up to date and only execute the rules necessary to update the files which aren't. It will also stop if one of the commands carried out will return a non-zero error level (compilers do that when encountering severe errors).
You should now be able to understand the manual and work out your little makefile.
Due to strict policies regarding cheating, I can't tell you exactly, but I'll give an example with the undergrad project I made for a course about data structures.
I had the files
All .c files but main.c were sorting and finding algorithms. The main.c was obviously the main program which took the measurements and the Makefile is the, well, makefile.
I wrote this:
The CC variable is the compiler name. Set it to cc or gcc.
The DEBUG will set a define flag, forget it
the CFLAGS are the options to the compiler. You will have your own. The most common ones are -W or -Wall, -ggdb if you want debug symbols, --std=c99 sets the language dialect (forget it), -pedantic rejects extensions (like gnu89), the -D(DEBUG) passes the aforementioned DEBUG symbol which you won't use, and the other -Wx flags just forget them.
OBJ variable containes ALL the object code binaries that the main program needs, ie all intermediary files of compilations of bubble.c, csbubble.c etc. ATTENTION: If you forget to include even a single object file, your make will fail! Include all your .c files but main.c with the .o extension, as I did.
Let's focus at the rest lines:
The first field is the target. It's called "all", followed by a colon. If you type "make all", this target will be activated. After a TAB, there is the list of all dependencies. There you will put ANY object file your program will need, that is the $OBJ (either type $OBJ or $(OBJ) doesn't matter).
After these dependencies are satisfied, the next lines will execute, up until the next target.
Make will find no bubble.o So it will compile bubble.c with $CFLAGS to get bubble.o. Then will find no csbubble.o, and it will compile csbubble.c, etc. There is NO NEED to put a target for each .c file, as many students do. Make knows how to invoke gcc.
When Make finishes, it will proceed with the next line.
There it calls the compiler ($CC) with $CFLAGS to compile main.c and link it against the object files ($OBJ) and the math library (-lm, you won't need that). The -o main means "the output will be called main. If you don't specify it, it defaults to a.out (assembler output, for the history).
Next will find the clean: target and stop.
If you invoke make as "make clean", then this target will be fired.
Here I delete all backup files (*~) all object files (*.o), the main executable and core dump (forget this).
You could just put "rm -f *.o helloworld"
in RHEL 6.10, how can we make the the df -k return the output without wrapping. And wihout using the df -Pk option. After we patched a Linux server from 6.5 to 6.10:
The df -k on RHAT 6.10 it wraps the line for ex:
6.10:
/dev/mapper/vgapp01-vendor
... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
]Compile cpp2html.c to produce cpp2html.o.
( Important: the source code in these files is C, not C++, and so... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Compile cpp2html.c to produce cpp2html.o.
( Important: the source code in these files is C, not C++, and so... (8 Replies)
dears
what i need to make is
cp -irp file_name filename
tar cvf filename.tar filename
gzip filename.tar
in one commane using exec
it that prossible and how can i do that (4 Replies)
hi, I'was trying to compile a simple game , just for testing the system, but the make command gave me problems, so I read that it was best to have a gnu make package installed so I made
pkgrm SUNWgmake
and installed the gnu make from sunfreesoftware, the problem is that now when I run make... (9 Replies)
Hi
After downloading and compiling new ntp source for Solaris 10 I used the make command on the ntp directory.
I received the following output:
bash-3.00# make
(bk version) >/dev/null 2>&1 && \
cd . && \
x=`bk -R prs -hr+ -nd:I: ChangeSet` && \
y=`cat version... (2 Replies)
Hey Guys....
I installed Solaris 10 (10/08) on _X86 platform, I need install any software of load balance. I find the pen-0.18.0-sol10-x86-local software.
I cant finish the install process , i dont find the make command, I think this command is associated to the C compiler process.
But... (2 Replies)
hi
i tried to search for the "make" command but to no avail.
this is what happens:
when i try to type the "make" command,
it prompt me the error "
csh:make:not found
***error code 1
make:Fatal error: command fail for target 'all' "
i have just freshly install solaris 9 on my server.... (8 Replies)
Dear Guys ,
Kindly note that i have sun solaries 8 intel machine .
i installed apache and it is working fine .
i am installing perl5 , MD5 and CGI .
but whenever i execute the commands , make , make test and make install i get error message : not found
# make
make: not found
also i... (2 Replies)