Find the answer to your Linux question:
Results 1 to 6 of 6
hi all, Any one know how to create a makefile.i have 11 c files and its headers and also some header files are in folder,ie include.then how to create a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2012
    Posts
    42

    makefile creation


    hi all,
    Any one know how to create a makefile.i have 11 c files and its headers and also some header files are in folder,ie include.then how to create a makefile for this type of file.

    please give me a solution...

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by tintu1212 View Post
    hi all,
    Any one know how to create a makefile.i have 11 c files and its headers and also some header files are in folder,ie include.then how to create a makefile for this type of file.

    please give me a solution...
    Hi,

    as to passing the C files to the compiler, just put them on the command line in your make command. you can use an asterisk if you just want to grab all in the cwd. you can put the path to the header file(s) as -I"/dirname" options. here is an example:
    Code:
    DIR1=/tmp/inc1
    DIR2=/tmp/inc2
    INC=$(DIR1) $(DIR2)
    INC_PARAMS=$(foreach d, $(INC), -I$d)
    CC      = /usr/bin/gcc
    STRIP   = /usr/bin/strip
    SRC     = foo.c
    OBJ     = foo.o
    EXE     = foo
    
    .c.o: $(INC)
            $(CC) $(INC_PARAMS) $(CFLAGS) -c $*.c
    #       $(CC) $(CFLAGS) -c $*.c
    all: $(EXE)
            $(STRIP) $(EXE)
    clean:
            rm -f *.o rm -f *% $(EXE)
    $(EXE): $(OBJ)
            $(CC) -o $(EXE) $(OBJ) $(LIBS)
    install :
            cp $(EXE) $(BINDIR)

  3. #3
    Just Joined!
    Join Date
    Feb 2012
    Posts
    42
    hi,
    when i giving make it will show following error,

    Makefile:12: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.

    pls give me a solution.

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by tintu1212 View Post
    when i giving make it will show following error,

    Makefile:12: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.

    pls give me a solution.
    on line 12:
    Code:
            $(CC) $(INC_PARAMS) $(CFLAGS) -c $*.c
    delete the spaces before $(CC) and replace them with a <Tab> character. Makefiles are indentation-finicky.

  5. #5
    Just Joined!
    Join Date
    Feb 2012
    Posts
    42
    hi,

    after that it gives following error,

    /usr/bin/gcc -o TRIMENG
    gcc: fatal error: no input files
    compilation terminated.
    make: *** [TRIMENG] Error 4

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by tintu1212 View Post
    after that it gives following error,

    /usr/bin/gcc -o TRIMENG
    gcc: fatal error: no input files
    compilation terminated.
    make: *** [TRIMENG] Error 4
    Can you post your whole Makefile? Wrap it in CODE tags. It is probably just a line-break/tab syntax thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •