diff --git a/Extensions/Terrain/Sample/makefile b/Extensions/Terrain/Sample/makefile
index 264a7a3..63743d0 100644
--- a/Extensions/Terrain/Sample/makefile
+++ b/Extensions/Terrain/Sample/makefile
@@ -4,7 +4,7 @@ OBJECTS = app.o main.o
 
 
 libHorde3D: $(OBJECTS)
-	g++ $(OBJECTS) -oSample_Terrain -L../../../Horde3D/Dependencies/Libs_Linux_x86 -L../../../Horde3D/Binaries/Linux_x86 -lglfw -lXrandr -lpthread -lHorde3D -lHorde3DUtils -lHorde3DTerrain -Wl,-rpath,'$$ORIGIN'
+	g++ $(OBJECTS) -oSample_Terrain -L../../../Horde3D/Dependencies/Libs_Linux_x86 -L../../../Horde3D/Binaries/Linux_x86 -lglfw -lXrandr -lpthread -lHorde3D -lHorde3DUtils -Wl,-rpath,'$$ORIGIN'
 	mv Sample_Terrain ../../../Horde3D/Binaries/Linux_x86
 
 %.o: %.cpp
diff --git a/Extensions/Terrain/Source/makefile b/Extensions/Terrain/Source/makefile
deleted file mode 100644
index 7342b9b..0000000
--- a/Extensions/Terrain/Source/makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# Terrain Extension
-
-OBJECTS = \
-	extension.o terrain.o
-
-libHorde3DTerrain: $(OBJECTS)
-	g++ $(OBJECTS) -olibHorde3DTerrain.so -shared
-	mv libHorde3DTerrain.so ../../../Horde3D/Binaries/Linux_x86/
-
-%.o: %.cpp
-	g++ -c $< -o$@ -I../../../Horde3D/Source/Shared -I../../../Horde3D/Source/Horde3D\ Engine -fPIC ${CFLAGS}
-
-
-clean:
-	rm *.o; rm ../../../Horde3D/Binaries/Linux_x86/libHorde3DTerrain.so
diff --git a/Horde3D/Bindings/C++/Horde3D.h b/Horde3D/Bindings/C++/Horde3D.h
index 18aabd9..f47ceb6 100644
--- a/Horde3D/Bindings/C++/Horde3D.h
+++ b/Horde3D/Bindings/C++/Horde3D.h
@@ -30,7 +30,7 @@
 #	if defined( WIN32 ) || defined( _WINDOWS )
 #		define DLL extern "C" __declspec( dllimport )
 #	else
-#		define DLL
+#		define DLL extern "C"
 #	endif
 #endif
 
diff --git a/Horde3D/Bindings/C++/Horde3DUtils.h b/Horde3D/Bindings/C++/Horde3DUtils.h
index 52c4a75..7b3e58c 100644
--- a/Horde3D/Bindings/C++/Horde3DUtils.h
+++ b/Horde3D/Bindings/C++/Horde3DUtils.h
@@ -32,7 +32,7 @@
 #	if defined( WIN32 ) || defined( _WINDOWS )
 #		define DLL extern "C" __declspec( dllimport )
 #	else
-#		define DLL
+#		define DLL extern "C"
 #	endif
 #endif
 
diff --git a/Horde3D/Source/Horde3D Engine/makefile b/Horde3D/Source/Horde3D Engine/makefile
index 90c5775..409eefd 100644
--- a/Horde3D/Source/Horde3D Engine/makefile	
+++ b/Horde3D/Source/Horde3D Engine/makefile	
@@ -1,19 +1,24 @@
 # Horde3D Engine
 
-OBJECTS = \
+HORDE3D = \
 	egAnimatables.o egAnimation.o egCamera.o egCom.o egExtensions.o egGeometry.o egLight.o egMain.o \
 	egMaterial.o egModel.o egModules.o egParticle.o egPipeline.o egPrimitives.o egRendererBase.o \
 	egRenderer.o egResource.o egScene.o egSceneGraphRes.o egShader.o egTextures.o \
 	utImage.o utOpenGL.o ../Shared/utXMLParser.o
 
+TERRAIN = \
+	extension.o terrain.o
+
+
+OBJECTS = $(HORDE3D) $(addprefix ../../../Extensions/Terrain/Source/, $(TERRAIN))
 
 libHorde3D: $(OBJECTS)
 	g++ $(OBJECTS) -olibHorde3D.so -lGL -shared
 	mv libHorde3D.so ../../Binaries/Linux_x86
 
 %.o: %.cpp
-	g++ -c $< -o$@ -I../Shared -I../../Extensions -fPIC ${CFLAGS}
+	g++ -c $< -o$@ -I../Shared -I../../../Extensions -I../../../Horde3D/Source/Shared -I../../../Horde3D/Source/Horde3D\ Engine -fPIC ${CFLAGS}
 
 
 clean:
-	rm *.o; rm ../../Binaries/Linux_x86/libHorde3D.so
+	rm $(OBJECTS) 2> /dev/null; rm ../../Binaries/Linux_x86/libHorde3D.so 2> /dev/null
diff --git a/Horde3D/Source/Horde3D Engine/utImage.cpp b/Horde3D/Source/Horde3D Engine/utImage.cpp
index 2df89be..14a5504 100644
--- a/Horde3D/Source/Horde3D Engine/utImage.cpp	
+++ b/Horde3D/Source/Horde3D Engine/utImage.cpp	
@@ -1257,7 +1257,7 @@ static int process_frame_header(int scan)
          }
          return e("outofmem", "Out of memory");
       }
-      img_comp[i].data = (uint8*) (((int) img_comp[i].raw_data + 15) & ~15);
+      img_comp[i].data = (uint8*) (((size_t) img_comp[i].raw_data + 15) & ~15);
       img_comp[i].linebuf = NULL;
    }
 
diff --git a/Horde3D/Source/Shared/utPlatform.h b/Horde3D/Source/Shared/utPlatform.h
index 8a65044..1fbb172 100644
--- a/Horde3D/Source/Shared/utPlatform.h
+++ b/Horde3D/Source/Shared/utPlatform.h
@@ -43,13 +43,13 @@
 #	ifdef PLATFORM_WIN
 #		define DLLEXP extern "C" __declspec( dllexport )
 #	else
-#		define DLLEXP
+#		define DLLEXP extern "C"
 #	endif
 #endif
 
 #ifndef PLATFORM_WIN
 #	define _stricmp strcasecmp
-#	define _mkdir( name ) mkdir( name, -1 )
+#	define _mkdir( name ) mkdir( name, 0755 )
 #endif
 
 // The following lines will produce a compiler error if integer types have unexpected sizes
