Make Files

This is a discussion on Make Files within the C Programming forums, part of the General Programming Boards category; hi- I've just found myself thrust into compiling some c modules and I have to use make files options. I ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    2

    Make Files

    hi-

    I've just found myself thrust into compiling some c modules and I have to use make files options. I have a bit of a learning curve in front of me.

    could someone please direct me to a few good sites describing make files, particularly in gcc? Tutorial sites?

    thx

  2. #2
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88
    Code:
     
    #include <fstream>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      char str[10];
    
      //Creates an instance of ofstream, and opens example.txt
      ofstream a_file ( "example.txt" );
      // Outputs to example.txt through a_file
      a_file<<"This text will now be inside of example.txt";
      // Close the file stream explicitly
      a_file.close();
      //Opens for reading the file
      ifstream b_file ( "example.txt" );
      //Reads one string from the file
      b_file>> str;
      //Should output 'this'
      cout<< str <<"\n";
      // b_file is closed implicitly here
    }
    from www.cprogramming.com
    PLay MystWind beta , within two years

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    MystWind: I don't think that is what shipyard meant. Also, this is the C board not C++

    I've never written a makefile before but here is what google returned

    http://oucsace.cs.ohiou.edu/~bhumphre/makefile.html
    Last edited by sand_man; 03-13-2005 at 06:22 AM.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    Maybe you can find your answer here how to execute more than one files??
    When no one helps you out. Call google();

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    12

    quite the same prob....

    urmmm...

    i've just manage to run my MakeFile....I now i'm working on the DEbUG mode.... i use the Borland compiler though...slightly different files n command but maybe u can apply it to whatever u're trying to work out
    ym id >>>>> asmahmazlan

  6. #6
    Registered User joed's Avatar
    Join Date
    Mar 2004
    Posts
    59
    I'm not a makefile expert, but this is at least a simple example of one:
    Code:
    INCL   = header.h
    SRC    = file1.c file2.c file3.c
    OBJ    = $(SRC:.c=.o)
    LIBS   = -lcomctl32
    EXE    = a.exe
    
    # compiler stuff
    CC      = gcc
    CFLAGS  = -O3
    LDFLAGS =  -o $(EXE) $(LIBS) 
    CFDEBUG = -g -DDEBUG $(LDFLAGS)
    RM      = rm -f
    
    # create object files
    %.o: %.c
        $(CC) -c $(CFLAGS) $*.c -o $*.o
    
    # linker objects
    $(EXE): $(OBJ)
        $(CC) $(OBJ) menu.o $(LDFLAGS) -mwindows
    
    # object-dependent libraries
    $(OBJ): $(INCL)
    
    # make debug
    debug:
        $(CC) $(CFDEBUG) $(SRC)
    
    # make clean
    clean:
        $(RM) $(OBJ) $(EXE)

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    2
    thanks for the links and examples.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile producing a list of files.
    By leonm54 in forum Tech Board
    Replies: 1
    Last Post: 07-23-2007, 10:54 AM
  2. trying to make a KenGen ( for a game tool )
    By lonewolfy in forum C# Programming
    Replies: 4
    Last Post: 03-28-2007, 09:23 AM
  3. make variables visible on multiple files
    By jagerhans in forum C++ Programming
    Replies: 4
    Last Post: 08-28-2004, 07:32 PM
  4. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 01:43 PM
  5. Help with Header/Make files
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 04-10-2002, 11:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21