Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 2008 22:59:36 -0400
From:      Eduardo Cerejo <ejcerejo@optonline.net>
To:        FreeBSD-questions@FreeBSD.org
Subject:   Gcc and make not producing executable
Message-ID:  <20080318225936.9ef5af16.ejcerejo@optonline.net>

next in thread | raw e-mail | index | archive | help
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/gccintro_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.










Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080318225936.9ef5af16.ejcerejo>