Gcc and make not producing executable

Eduardo Cerejo ejcerejo at optonline.net
Tue Mar 18 19:59:40 PDT 2008


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"

main (void)
  hello ("world");
  return 0;

File hello_fn.c with the following code:

#include <stdio.h>
#include "hello.h"

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:

main: main.o hello_fn.o

        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:

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.

More information about the freebsd-questions mailing list