Forum Navigation
Forum breadcrumbs - You are here:WeLoveGod RallysPublic Forums: fbcocoaMakefile
You need to log in to create posts and topics.

Makefile

Posted by: svanvoorst <svanvoorst@...>

This demo will allow you to create a binary executable using a makefile.  This entire process may be automated with NSTask and .m files may be substituted for the .c file.  The complexity is obviously much greater for large projects.  The advantage of using makefile is that you can type just one command each time you make source code changes and it is smart enough to know which files need to be recompiled and which do not based on time stamps of the modified files.

Procedure and things you will need:

1) TextWrangler or suitable editor.
2) Folder named HelloWorld (or whatever you like)
3) Place two files in that folder, hello.c and makefile (source code shown below)
4) Migrate to the folder using Terminal (cd to change directories, ls to see what is in each directory if you don't know)
5) When Terminal shows that you are in your folder, type make and it should create a binary called hello (looks like a tv set)
6) Still in Terminal (and still in your folder) type ./hello and it should run your executable binary
7) If things have gone as planned you should see "Hello world" in your Terminal window.
8) One gotcha is the second line in the makefile has to start with a TAB (won't work if you don't)
9) Let me know if you have problems.

'------ start of hello.c file -----

#import <stdio.h>

int main()

{

  printf("Hello, world.n");

  return 0;

}

'----- end of hello.c file -------

'----- start of makefile ------

hello : hello.c
gcc hello.c -o hello

'----- end of makefile -------

Steve Van Voorst


To unsubscribe, e-mail: fbcocoa-unsubscribe@welovegod.org
For additional commands, e-mail: fbcocoa-help@freegroups.net