Q:

Program compiled on Linux not getting code in #ifdef section

I have a cross platform program I am working on that has several files with 
#ifdef WIN32
...inclues
#endif
#ifdef LINUX
..inlcudes
#endif

when I went to compile on LINUX I keep getting errors about not finding functions and such, but if i comment out the #ifdef LINUX blocks (still keeping the includes uncommented) it works, so it seams as if my define is not working properly.
This is my make file (file names changed):
CC  = gcc
CPP = g++

CFLAGS = -DLINUX $(INCLUDES) -c -g -O0 -Wall -fpic

INCLUDES = -I. 

LFLAGS += -fpic -shared

LFLAGS += -lpthread

CFILES = a.c b.c c.c d.c e.c f.cpp g.cpp h.cpp i.cpp

##all:   $(SFILES:.s=.s.o) $(CFILES:.c=.o) $(CFILES:.cpp=.o)
##  $(CPP) $(INCLUDES) $(LFLAGS) -o libclient.so.1.0 $(CFILES:.c=.o) $(CFILES:.cpp=.o)

all:   $(SFILES:.s=.s.o) $(CFILES:.c=.o)
    $(CPP) $(INCLUDES) $(LFLAGS) -o libclient.so.1.0 $(CFILES:.c=.o) 

%.o : %.c

    $(CPP) -c $(CFLAGS) $< -o $@

%.o : %.cpp

    $(CPP) -c $(CFLAGS) $< -o $@

clean:

    rm *.o libclient.so.1.0

A:

First make sure you're using the proper command, so copy paste the output from Makefile and execute that from your shell (by hand).
Maybe your define is undefined along the way so, here are two approaches to find out what's wrong:
1) include #warning statement(s) within your ifdef to see if it is really a missing define:
#warning "before the define"
#ifdef LINUX
#warning "here goes the linux define" 
..inlcudes
#endif

if you compile the code and don't see the warning then indeed you miss the define somewhere.
2) Check the preprocessor output. To do so send the preprocessor (use cpp not g++) output to stdout by using the -E flag. (cpp -E ....)
By looking at output you can see all code included, so you can track down in detail what code your compiler gets. I find that method of last resort usually giving most insight into
weird problems.

A:

Your make file actually does work for c files, but not for c++ files.
This is because you invoke your custom compile command line for c compilation but your cpp files are going directly into what is effectively your link command line which does not specify compilation flags.

