parentmop.blogg.se

Makefile for c program executable command
Makefile for c program executable command













makefile for c program executable command

larcadia -lcorinth -lyaml-cpp -lzmq -lhiredis -lbondoas LIB := -L /usr/local/lib -lsantacruzengine -lsantacruzlib \ INC := -I include $(INCLIST) -I /usr/local/include The $(BUILDLIST) variable creates a list of pathed subfolders for the build folder, where include/caches becomes build/caches for the compile step.

makefile for c program executable command

For example include/caches is transformed into -I include/caches. The $(INCLIST) variable is a transformation of $(INCDIRS) into the format needed as compiler flags. So, the $(INCDIRS) variable contains a unique list of subfolders under the include folder where all my header files reside. This way I can re-arrange the code-base by moving files around, not change anything and it still compiles and runs. Instead of #include "./caches/session_cache.h" I simply use #include "session_cache.h") and expect the compiler to figure it where things are. The next set of lists are used to build the list of include folders and related lists.Īside: I am one of those quirky C++ programmers that does not use pathed #includes (e.g. INCLIST := $(patsubst include/%,-I include/%,$(INCDIRS))īUILDLIST := $(patsubst include/%,$(BUILDDIR)/%,$(INCDIRS)) INCDIRS := $(shell find include/**/* -name '*.h' -exec dirname \ | sort | uniq) # Note: Intentionally excludes the root of the include folder $(SRCEXT )) OBJECTS := $(patsubst $(SRCDIR )/%, $(BUILDDIR )/%, $(SOURCES. SOURCES := $(shell find $(SRCDIR ) -type f -name *. TARGET := $(TARGETDIR )/ $(EXECUTABLE ) # Final Paths Ifeq ( $( UNAME_S ) ,Darwin) CC := clang++ -arch x86_64 # HIL: No spaces or comments after otherwise it captures them! # Copyright (c) 2015 Maritime Capital LP. Scroll below to see the breakdown and why I did it this way. Īs expected, the C++ source files are under the src folder and includes are in the include tree.Īnd here is the Makefile, the actual one I am using. The project is laid out as follows (most of the source files have been removed to shorten the list). I have selected one of my real projects for this post. For Library builds, I have a similar, but different Makefile, see The Simple C++ Makefile - Library Edition (Coming Soon). In this post I will show you the Makefile I use for multi-platform C++ executable builds and explain what each line and command does in detail.

makefile for c program executable command

To compile and deploy (and to test compiles and deploys), I use standard Unix Makefiles, available almost everywhere. However, Xcode is not available on Linux.

Makefile for c program executable command code#

I follow the Simple C++ Project Structure (and the Xcode edition) to code up each product. I develop a lot of applications in C++ using Xcode on OS X and deploy them to CentOS Linux Servers to run.















Makefile for c program executable command