View Full Version : Makefile

June 29th, 2012, 07:06 AM
we are a groups of student of an Argentina university and need help to do a Makefile, we have to do one and no have any idea of how.... If someone know and want to tell us. We will apreciate your answer.

I want to compile this...


#include <stdio.h>
#include <funcion1.h>

int main(void)
return 0;


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

void escribeHolaMundo(void)
printf("Hola Mundo\n");


void escribeHolaMundo(void);

June 29th, 2012, 07:29 AM
It depends on how complex you want to have your build process. There tend to be a large number of conventions that go into writing makefiles, but a very basic layout of one follows:

program : main.o funcion.o
gcc -Wall -g -o program main.o funcion.o

main.o : main.c
gcc -Wall -g -c -o main.o main.c

funcion.o : funcion.c
gcc -Wall -g -c -o funcion.o function.c

This code does not have proper spacing, so you can't directly copy/paste it.

Also, generally in a makefile, the actual system commands, targets, and source files are encapsulated in variables. Here is a link to the GNU Make manual. Also, including "funcion.h" in brackets may cause it to fail. Try switching that to be in quotes.


June 29th, 2012, 07:33 AM

June 29th, 2012, 07:41 AM
While we are happy to serve as a resource for hints and for asking questions when you get stuck and need a little help, the Ubuntu Forums is not a homework service. Please do not post your homework assignments expecting someone else to do it for you. Any such threads will be taken offline and warnings or infractions may be issued.