Fix PLIST_API definitions
diff --git a/configure.ac b/configure.ac
index c6cb4bc..bf1131d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -174,7 +174,7 @@
 fi
 AM_CONDITIONAL([HAVE_CYTHON],[test "x$cython_python_bindings" = "xyes"])
 
-AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wredundant-decls -Wshadow -Wpointer-arith  -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Wno-strict-aliasing -fvisibility=hidden $PTHREAD_CFLAGS")
+AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wredundant-decls -Wshadow -Wpointer-arith  -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Wno-strict-aliasing $PTHREAD_CFLAGS")
 GLOBAL_LDFLAGS="$PTHREAD_LIBS"
 
 AC_ARG_ENABLE(debug,
@@ -192,7 +192,17 @@
        GLOBAL_CFLAGS+=" -g"
 fi
 
+if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
+	GLOBAL_CFLAGS+=" -DLIBPLIST_STATIC"
+fi
+
+GLOBAL_CXXFLAGS=$GLOBAL_CFLAGS
+AS_COMPILER_FLAG([-fvisibility=hidden], [
+  GLOBAL_CFLAGS+=" -fvisibility=hidden"
+], [])
+
 AC_SUBST(GLOBAL_CFLAGS)
+AC_SUBST(GLOBAL_CXXFLAGS)
 AC_SUBST(GLOBAL_LDFLAGS)
 
 case "$GLOBAL_CFLAGS" in
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 47eda51..0a9f5ee 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -75,17 +75,11 @@
 #endif
 /*}}}*/
 
-#ifdef LIBPLIST_STATIC
-  #define PLIST_API
-#elif defined(_WIN32)
-  #ifdef DLL_EXPORT
-    #define PLIST_API __declspec(dllexport)
-  #else
+#ifndef PLIST_API
+  #ifdef LIBPLIST_STATIC
+    #define PLIST_API
+  #elif defined(_WIN32)
     #define PLIST_API __declspec(dllimport)
-  #endif
-#else
-  #if __GNUC__ >= 4
-    #define PLIST_API __attribute__((visibility("default")))
   #else
     #define PLIST_API
   #endif
diff --git a/src/Array.cpp b/src/Array.cpp
index d86d021..bc448d3 100644
--- a/src/Array.cpp
+++ b/src/Array.cpp
@@ -18,11 +18,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <plist/Array.h>
-
+#include <cstdlib>
 #include <algorithm>
 #include <climits>
-#include <cstdlib>
+#include "plist.h"
+#include <plist/Array.h>
 
 namespace PList
 {
diff --git a/src/Boolean.cpp b/src/Boolean.cpp
index 2c871c8..9ec1a63 100644
--- a/src/Boolean.cpp
+++ b/src/Boolean.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Boolean.h>
 
 namespace PList
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 4e7e19c..30c20b6 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Dictionary.h>
 
 namespace PList
diff --git a/src/Integer.cpp b/src/Integer.cpp
index 7fa0f93..30a5405 100644
--- a/src/Integer.cpp
+++ b/src/Integer.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Integer.h>
 
 namespace PList
diff --git a/src/Key.cpp b/src/Key.cpp
index 5f8d205..79265d5 100644
--- a/src/Key.cpp
+++ b/src/Key.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Key.h>
 
 namespace PList
diff --git a/src/Makefile.am b/src/Makefile.am
index e4b39ae..1a416ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,7 @@
 	-I$(top_srcdir)/libcnary/include
 
 AM_CFLAGS = $(GLOBAL_CFLAGS)
+AM_CXXFLAGS = $(GLOBAL_CXXFLAGS)
 AM_LDFLAGS = $(GLOBAL_LDFLAGS)
 
 lib_LTLIBRARIES = \
diff --git a/src/Node.cpp b/src/Node.cpp
index 08a91b0..0bd428a 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Node.h>
 #include <plist/Structure.h>
 #include <plist/Dictionary.h>
diff --git a/src/String.cpp b/src/String.cpp
index aee2358..2ddc28b 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/String.h>
 
 namespace PList
diff --git a/src/Structure.cpp b/src/Structure.cpp
index 4be4e7d..670cce6 100644
--- a/src/Structure.cpp
+++ b/src/Structure.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Structure.h>
 
 namespace PList
diff --git a/src/Uid.cpp b/src/Uid.cpp
index e83ed27..8c73c80 100644
--- a/src/Uid.cpp
+++ b/src/Uid.cpp
@@ -19,6 +19,7 @@
  */
 
 #include <cstdlib>
+#include "plist.h"
 #include <plist/Uid.h>
 
 namespace PList
diff --git a/src/bplist.c b/src/bplist.c
index 953c2c7..93f0bc6 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -32,11 +32,11 @@
 #include <ctype.h>
 #include <inttypes.h>
 
-#include <plist/plist.h>
 #include "plist.h"
 #include "hashtable.h"
 #include "bytearray.h"
 #include "ptrarray.h"
+#include "plist/plist.h"
 
 #include <node.h>
 
diff --git a/src/plist.h b/src/plist.h
index 178fb7c..a993e3a 100644
--- a/src/plist.h
+++ b/src/plist.h
@@ -26,8 +26,6 @@
 #include <config.h>
 #endif
 
-#include "plist/plist.h"
-
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -39,6 +37,20 @@
 #include <sys/time.h>
 #endif
 
+#ifdef LIBPLIST_STATIC
+  #define PLIST_API
+#elif defined(_WIN32)
+  #define PLIST_API __declspec( dllexport )
+#else
+  #if __GNUC__ >= 4
+    #define PLIST_API __attribute__((visibility("default")))
+  #else
+    #define PLIST_API
+  #endif
+#endif
+
+#include "plist/plist.h"
+
 struct plist_data_s
 {
     union