Makefile help

This is a discussion on Makefile help within the C Programming forums, part of the General Programming Boards category; I want to change this command line compile code: gcc -Wall project.c -o outputFile -lposix4 to the following makefile: Code: ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    43

    Makefile help

    I want to change this command line compile code:
    gcc -Wall project.c -o outputFile -lposix4

    to the following makefile:

    Code:
    CC = gcc
    DEBUG = -g
    CFILES = project.c
    HFILES = 
    
    outputFile: $(CFILES) $(HFILES)
            $(CC) $(DEBUG) -o outputFile $(CFILES)
    
    clean:
            rm outputFile
    However, I don't know how to get that library added to my makefile. Anyone know how?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
        $(CC) $(DEBUG) -o outputFile $(CFILES) -lposix4
    Probably like that. Or add a section for flags:
    Code:
    CCFLAGS = -Wall -lposix4
    http://en.wikipedia.org/wiki/Make_(software)


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    43
    Quote Originally Posted by quzah View Post
    Code:
        $(CC) $(DEBUG) -o outputFile $(CFILES) -lposix4
    Probably like that. Or add a section for flags:
    Code:
    CCFLAGS = -Wall -lposix4
    http://en.wikipedia.org/wiki/Make_(software)


    Quzah.
    Thank you sir, it works now.

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by hansel13 View Post
    Thank you sir, it works now.
    Well done Hansel; you have climbed many conceptual mountains this week. I maintain your aptitude would be wasted in sales or marketing.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    43
    Quote Originally Posted by jeffcobb View Post
    Well done Hansel; you have climbed many conceptual mountains this week. I maintain your aptitude would be wasted in sales or marketing.
    We will see. My Dad is an engineer and works at Intel, so I might just follow in his footsteps there. Really depends on what school I get into for my Masters and how life plays out. Thanks for your help again on that consumer/producers problem. You'll probably see me post here a bit more this fall.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile help please
    By TriKri in forum C++ Programming
    Replies: 3
    Last Post: 09-24-2009, 12:36 AM
  2. Replies: 2
    Last Post: 08-11-2009, 06:45 AM
  3. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 10:50 PM
  4. makefile
    By twans in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2005, 12:16 AM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM

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