Makefiles - Compile all .cpp files in src/ to .o's in obj/, then link to binary in /
        Posted  
        
            by Austin Hyde
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Austin Hyde
        
        
        
        Published on 2010-05-25T19:57:10Z
        Indexed on 
            2010/05/25
            20:01 UTC
        
        
        Read the original article
        Hit count: 528
        
So, my project directory looks like this:
/project
    Makefile
    main
    /src
        main.cpp
        foo.cpp
        foo.h
        bar.cpp
        bar.h
    /obj
        main.o
        foo.o
        bar.o
What I would like my makefile to do would be to compile all .cpp files in the /src folder to .o files in the /obj folder, then link all the .o files in /obj into the output binary in the root folder /project.
The problem is, I have next to no experience with Makefiles, and am not really sure what to search for to accomplish this.
Also, is this a "good" way to do this, or is there a more standard approach to what I'm trying to do?
© Stack Overflow or respective owner