Thread: makefile

  1. #1
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528

    makefile

    I am running into some linking errors when I try to compile a C++ program using a Makefile. I have checked out the documentation but it seems I am missing something and maybe someone can easily spot it out.Here is the Makefile
    PHP Code:
    target main
    CPPFLAGS 
    += -Wall -Wextra -g
    linker
    =ld
    libs
    +=lsmfl-window -lsmfl-graphics
    LDFLAGS
    +=$(libs)
    $(
    target):main.o       
                
    $(CXX) $(LDGLAGS) $^ -$@ 
    main.omain.cc
               
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -$< -$@
    .
    PHONY:clean
               
    $(RM) -*.$(target
    Last edited by Aslaville; 07-30-2013 at 04:02 AM.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Where are your CXX, CXXFLAGS and RM variables defined?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    Quote Originally Posted by vart View Post
    Where are your CXX, CXXFLAGS and RM variables defined?
    Yes they are defined by default.
    This works :
    PHP Code:
    target main
    CPPFLAGS 
    += -Wall -Wextra -g
    libs
    =lsmfl-window -lsmfl-graphics 
    LDFLAGS
    +=$(libs)
    $(
    target):main   
             
    $(CXX) $(LDGLAGS) $^ -$@ 
    main.o  main.cc  
             
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -$< -$@    
    .
    PHONY:clean
    clean
    :
             $(
    RM) -*.$(target
    This doesn't :
    PHP Code:
    target main
    linker
    =ld
    CPPFLAGS 
    += -Wall -Wextra -g
    libs
    =lsmfl-window -lsmfl-graphics
     LDFLAGS
    +=$(libs)
    $(
    target):main.o
            
    $(linker) $(LDGLAGS) $^ -$@ 
    main.omain.cc
           
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -$< -$@
    .
    PHONY:clean
         clean
    :    $(RM) -*.$(target
    So I got with the first one.I guess ld doesn.t link to libC++ by default
    Last edited by Aslaville; 07-30-2013 at 04:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile
    By vin_pll in forum C++ Programming
    Replies: 2
    Last Post: 01-12-2010, 12:14 AM
  2. Not sure how to put this into a Makefile
    By redruby147 in forum C Programming
    Replies: 4
    Last Post: 07-07-2009, 12:45 PM
  3. makefile
    By shuo in forum C++ Programming
    Replies: 1
    Last Post: 11-18-2007, 01:41 AM
  4. difference makefile makefile.am makefile.in
    By Bargi in forum Linux Programming
    Replies: 7
    Last Post: 10-28-2007, 02:08 PM
  5. makefile
    By natasha_adams in forum C Programming
    Replies: 1
    Last Post: 01-16-2006, 02:26 PM