diff --git a/examples/user_types/Makefile b/examples/user_types/Makefile
index e1ab9a2b1dbc2f9c145741502766b051247a887e..d999b890e941b15f3b35c1dbb08b627d865aabfd 100644
--- a/examples/user_types/Makefile
+++ b/examples/user_types/Makefile
@@ -76,19 +76,19 @@ run:
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_j
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_j
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_j
 
 	@echo "************ running python decoder (from wiki_example):"
 	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_j LabComm2014
 
 	@echo "************ running C encoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_encoder encoded_data_c
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_encoder encoded_data_c
 
 	@echo "************ running Java  decoder: *****************"
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_c
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_c
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_c
 
 	@echo "************ running python decoder (from wiki_example):"
 	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_c LabComm2014
@@ -100,7 +100,7 @@ run:
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
 
 	@echo "************ running python decoder (from wiki_example):"
 	PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
@@ -118,22 +118,22 @@ runwcs: build ExampleEncoder.exe ExampleDecoder.exe
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_j
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_j
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_j
 
 	@echo "************ running python decoder (from wiki_example):"
 	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_j LabComm2014
 
 	@echo "************ running C# decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ mono ./ExampleDecoder.exe encoded_data_j
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ mono ./ExampleDecoder.exe encoded_data_j
 
 	@echo "************ running C encoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_encoder encoded_data_c
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_encoder encoded_data_c
 
 	@echo "************ running Java  decoder: *****************"
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_c
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_c
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_c
 
 	@echo "************ running python decoder (from wiki_example):"
 	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_c LabComm2014
@@ -148,7 +148,7 @@ runwcs: build ExampleEncoder.exe ExampleDecoder.exe
 	@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
 
 	@echo "************ running C decoder: *****************"
-	@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
+	@${LD_LIBRARY_PATH_NAME}=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
 
 	@echo "************ running C# decoder: *****************"
 	@mono ./ExampleDecoder.exe encoded_data_p
diff --git a/lib/c/os_compat.mk b/lib/c/os_compat.mk
index 505c7a2f930b639e22f140698b62cb1ab12d9a8a..4f1774a1da12c713a54c83dc1b8540ab8505a53d 100644
--- a/lib/c/os_compat.mk
+++ b/lib/c/os_compat.mk
@@ -10,6 +10,7 @@ ifeq ($(UNAME_S),Linux)
   CFLAGS_TEST=$(CFLAGS) -Itest
   LDFLAGS=-L..
   LDLIBS=-llabcomm$(LIBVERSION) -lrt
+  LD_LIBRARY_PATH_NAME=LD_LIBRARY_PATH
   MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt
 else ifeq ($(UNAME_S),Darwin)
   #CC=$(CROSS_COMPILE)clang
@@ -24,6 +25,7 @@ else ifeq ($(UNAME_S),Darwin)
   CFLAGS+=-std=c99
   LDFLAGS=-L..
   LDLIBS=-llabcomm$(LIBVERSION)
+  LD_LIBRARY_PATH_NAME=DYLD_LIBRARY_PATH
   MAKESHARED=clang -o $1 -shared -Wl,-install_name,$2 $3 -lc
 else ifneq ($(findstring CYGWIN,$(UNAME_S)),)
   CC=$(CROSS_COMPILE)gcc