[HN Gopher] Using `make` to compile C programs
       ___________________________________________________________________
        
       Using `make` to compile C programs
        
       Author : mfrw
       Score  : 14 points
       Date   : 2025-06-11 03:24 UTC (3 days ago)
        
 (HTM) web link (jvns.ca)
 (TXT) w3m dump (jvns.ca)
        
       | kazinator wrote:
       | CPPFLAGS and CXXFLAGS are different. CPPFLAGS are for options for
       | the C preprocessor, regardless of what language it is being used
       | for. CXXFLAGS are for C++. The XX's are ++ rotated 45 degrees.
       | 
       | Don't be fooled by the convention used in some necks of the woods
       | of a .cpp suffix for C++ files; CPPFLAGS have to do with the
       | "cpp" program, not the .cpp suffix.
       | 
       | LDLIBS is sister to LDFLAGS. Both these variables hold options
       | for the linker command line destructured into two groups: LDFLAGS
       | are the early options that go before the object files. LDLIBS are
       | the -l options that give libraries, like -lssl -ldl -lcrypto ...
       | these go after the object files.
       | 
       | If you're writing a Makefile, with your own custom recipes for
       | linking, be sure you interpolate both LDFLAGS and LDLIBS in the
       | right places.
        
       | ashishb wrote:
       | I love Makefile. It is the easiest build system.
       | 
       | In my projects, whether the language is Go, Rust, Python,
       | typescript, or even Android, there are standard make commands, if
       | applicable, always work                 - make format       -
       | make lint       - make build       - make docker_build       -
       | make docker_run
       | 
       | Once might migrate from one build system eg pipenv to poetry to
       | uv, but the high level `make format` commands doesn't change.
        
       | jiehong wrote:
       | I wish more projects would include a dockerfile in which a
       | compiler and all dependencies are installed to run the right make
       | command as 'docker build .'
       | 
       | So you get a working build example, and if you're lucky and the
       | base image exists for your architecture, it'll compile a binary
       | for your system too (assuming static linking I guess).
        
       ___________________________________________________________________
       (page generated 2025-06-14 23:00 UTC)