C++ makefile for CPLEX with environment loading
Instead of providing your own %.o: %.cpp rule, you can let Make use its built-in one.  You need to pass your extra include directory, and the standard way to do that is to add to CXXFLAGS:
CXXFLAGS += -I$(CPX_INCDIR)

Or perhaps
CPLEX_DIR = /opt/ibm/ILOG/CPLEX_Studio126/cplex
CXXFLAGS += -I$(CPLEX_DIR)/include


Similarly, take advantage of the built-in link command; this is especially easy, as there's a built-in rule that will create main from main.o.  You need to tell Make to use the C++ linker rather than the plain (C) linker:
LINK.o = $(LINK.cc)
LDFLAGS += -L$(CPLEX_DIR)/lib/x86-64_linux/static_pic
LDLIBS += -lcplex -lm -pthread


To declare the dependency on the header file, note that main.o needs to be rebuilt whenever the header changes:
main.o: cpxmacro.h

That's all!
Header file dependencies can be hard to manage by hand in larger projects; for these, search for &quot;automatic dependency generation&quot;, or read Paul D. Smith's excellent article.

Modified makfile
With my changes:
CPLEX_DIR = /opt/ibm/ILOG/CPLEX_Studio126/cplex

CXX = g++
CXXFLAGS = -g -Wall -O
CXXFLAGS += -I$(CPLEX_DIR)/include

LINK.o = $(LINK.cc)
LDFLAGS += -L$(CPLEX_DIR)/lib/x86-64_linux/static_pic
LDLIBS += -lcplex -lm -pthread


all: main

main.o: cpxmacro.h


clean:
    $(RM) *~ *.o main

.PHONY: all clean