|
List Info
Thread: Gcc and make not producing executable
|
|
| Gcc and make not producing executable |
  United States |
2008-03-18 21:59:36 |
Hello,
I'm trying to get my feet wet in programming in C and the
first thing I'm doing is reading a book called an
Introduction to GCC. I'm running Fbsd 7-stable I have Gcc44
installed.
Example in the book is 3 files named main.c, hello_fn.c and
hello.h:
File main.c with the following code:
#include "hello.h"
int
main (void)
{
hello ("world");
return 0;
}
File hello_fn.c with the following code:
#include <stdio.h>
#include "hello.h"
void
hello (const char * name)
{
printf ("Hello, %s!n", name);
}
and hello.h with the following code:
void hello (const char * name);
Objective is to create a makefile which will create an
executable named main. The books has this code in the
Makefile:
CC=gcc
CFLAGS=-Wall
main: main.o hello_fn.o
clean:
rm -f main main.o hello_fn.o
The book says this should create two object files named
main.o and hello_fn.o plus an executable named main. But
the last is not created! Does it have to do with make
version? or is the book outdated (2005) http://www
.network-theory.co.uk/gcc/intro/
or you can the section that I'm referring to here:
http://www.network-theory.co.uk/docs/gccintro/gcci
ntro_16.html
By the way I can create the executable using gcc -Wall
main.c hello_fn.c -o main
so it's not a gcc problem I don't think.
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
| Re: Gcc and make not producing
executable |
  Netherlands |
2008-03-19 01:38:50 |
Eduardo Cerejo wrote:
> Objective is to create a makefile which will create an
executable named main. The books has this code in the
Makefile:
>
> CC=gcc
> CFLAGS=-Wall
> main: main.o hello_fn.o
>
> clean:
> rm -f main main.o hello_fn.o
>
> The book says this should create two object files named
main.o and hello_fn.o plus an executable named main.
gmake does the trick.
Otherwise your Makefile should look like this:
<begin Makefile>
main: main.o hello_fn.o
gcc main.o hello_fn.o -o main
main.o: main.c
gcc -c main.c
hello_fn.o: hello_fn.c
gcc -c hello_fn.c
clean:
rm -f main *.o
<end Makefile>
Or easier:
<begin Makefile>
CC=gcc
main: main.o hello_fn.o
$(CC) main.o hello_fn.o -o main
.c.o:
$(CC) $(CFLAGS) -c $<
clean:
rm -f main *.o
<end Makefile>
Peter
--
http://www.boosten.org
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
| Re: Gcc and make not producing
executable |
  United States |
2008-03-19 15:23:09 |
> gmake does the trick.
Indeed it did. Can you tell me what the main differences is
between make and gmake in terms of "making"? I
can see that gmake is gnu's version of make, is FreeBSD's
gmake the same as linux's make?
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
| Re: Gcc and make not producing
executable |
  Sweden |
2008-03-19 15:41:57 |
On Wed, Mar 19, 2008 at 04:23:09PM -0400, Eduardo Cerejo
wrote:
> > gmake does the trick.
>
> Indeed it did. Can you tell me what the main
differences is between make
> and gmake in terms of "making"? I can see
that gmake is gnu's version of
> make, is FreeBSD's gmake the same as linux's make?
gmake is the GNU project's version of 'make'.
The 'make' command installed on Linux systems is usually GNU
make.
FreeBSD uses its own version of 'make' and installs GNU make
under the name
'gmake' to avoid collision with the native make.
Both GNU make and FreeBSD's make has lots of extensions and
extra features
over a "standard" make program. Unfortunately
they have completely
different syntax for these extensions.
This means that while simple makefiles will work equally
well on either,
more complicated makefiles will typically work with either
one or the other
implementation of make, but rarely with more than one.
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013 student.uu.se
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
| Re: Gcc and make not producing
executable |
  United States |
2008-03-19 18:32:29 |
> On Linux systems, there is no base system 'make', so
GNU make is
> installed as 'make'. On FreeBSD systems, there is a
base system make
> that is maintained by the FreeBSD project, so GNU make
is installed as
> 'gmake'. The main differences in making with them is
that GNU make and
> FreeBSD make accept different arguments, and their
makefile syntaxes
> have discrepancies.
What kind of documentation is available on FreeBSD's make,
other than the man page? I was browsing through
/usr/share/doc/ but I didn't see anything related to make.
I saw pmake but not make.
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
| Re: Gcc and make not producing
executable |
  United States |
2008-03-20 20:57:36 |
> Eduardo Cerejo wrote:
> >> On Linux systems, there is no base system
'make', so GNU make is
> >> installed as 'make'. On FreeBSD systems, there
is a base system make
> >> that is maintained by the FreeBSD project, so
GNU make is installed as
> >> 'gmake'. The main differences in making with
them is that GNU make and
> >> FreeBSD make accept different arguments, and
their makefile syntaxes
> >> have discrepancies.
> >
> > What kind of documentation is available on
FreeBSD's make, other than the man page? I was browsing
through /usr/share/doc/ but I didn't see anything related to
make. I saw pmake but not make.
>
> From the make man page:
>
> PMake - A Tutorial. in /usr/share/doc/psd/12.make
I was aware of that tutorial, I was sure because it says
pmake, so pmake is the same as make, correct?
_______________________________________________
freebsd-questions freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribe freebsd.org"
|
|
[1-6]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|