Make getDefaultWireFormat call newInitialDefaultWireFormat if needed, instead of relying on a static initializer.
diff --git a/ndn-cpp/encoding/WireFormat.cpp b/ndn-cpp/encoding/WireFormat.cpp
index ba5772f..e208b82 100644
--- a/ndn-cpp/encoding/WireFormat.cpp
+++ b/ndn-cpp/encoding/WireFormat.cpp
@@ -10,9 +10,22 @@
 
 namespace ndn {
 
-ptr_lib::shared_ptr<WireFormat> WireFormat::initialDefaultWireFormat_(newInitialDefaultWireFormat());
+ptr_lib::shared_ptr<WireFormat> WireFormat::initialDefaultWireFormat_;
 
-WireFormat *WireFormat::defaultWireFormat_ = initialDefaultWireFormat_.get();
+WireFormat *WireFormat::defaultWireFormat_ = 0;
+
+WireFormat *WireFormat::getDefaultWireFormat()
+{
+  if (!defaultWireFormat_ && !initialDefaultWireFormat_) {
+    // There is no defaultWireFormat_ and we have not yet initialized initialDefaultWireFormat_, so initialize and use it.
+    // NOTE: This could have been done with a static initializer on initialDefaultWireFormat_, but this does not have
+    //   good cross-platform support, especially for dynamic shared libraries.
+    initialDefaultWireFormat_.reset(newInitialDefaultWireFormat());
+    defaultWireFormat_ = initialDefaultWireFormat_.get();
+  }
+  
+  return defaultWireFormat_;
+}
 
 ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeInterest(const Interest &interest) 
 {
diff --git a/ndn-cpp/encoding/WireFormat.hpp b/ndn-cpp/encoding/WireFormat.hpp
index 7eb9b31..fb4b9c2 100644
--- a/ndn-cpp/encoding/WireFormat.hpp
+++ b/ndn-cpp/encoding/WireFormat.hpp
@@ -37,10 +37,7 @@
    * setDefaultWireFormat.
    * @return A pointer to the WireFormat object.
    */
-  static WireFormat *getDefaultWireFormat() 
-  {
-    return defaultWireFormat_;
-  }
+  static WireFormat *getDefaultWireFormat();
   
 private:
   /**