title: Bjarne Stroustrup's header files compiling errors (PPP2 - Programming Principles & Practicing)
body: <p>I'm new to programming and I'm a student starting to learn C++. I would like to get ahead of my class with a good book about C++, the Programming Principles &amp; Practicing (Edition 2) was recommended to me for that purpose.
  I'm at the very first exercise called "Hello,World!" and I'm stuck because of some compiling errors. (I'm using Visual Studio 2015).</p>
  
  <p>As I try to run the program output shows this</p>
  
  <pre><code>1&gt;------ Rebuild All started: Project: Hello,World!, Configuration: Debug Win32 ------
  1&gt;  Hello,World!.cpp
  1&gt;MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
  1&gt;F:\DAE v2015\1) Programming\C++ Projects\Hello,World!\Debug\Hello,World!.exe : fatal error LNK1120: 1 unresolved externals
  ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  </code></pre>
  
  <p>His header file's code is the following:</p>
  
  <pre><code>/*
     std_lib_facilities.h
  */
  
  /*
      simple "Programming: Principles and Practice using C++ (second edition)" course header to
      be used for the first few weeks.
      It provides the most common standard headers (in the global namespace)
      and minimal exception/error support.
  
      Students: please don't try to understand the details of headers just yet.
      All will be explained. This header is primarily used so that you don't have
      to understand every concept all at once.
  
      By Chapter 10, you don't need this file and after Chapter 21, you'll understand it
  
      Revised April 25, 2010: simple_error() added
  
      Revised November 25 2013: remove support for pre-C++11 compilers, use C++11: &lt;chrono&gt;
      Revised November 28 2013: add a few container algorithms
      Revised June 8 2014: added #ifndef to workaround Microsoft C++11 weakness
  */
  
  #ifndef H112
  #define H112 251113L
  
  
  #include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;fstream&gt;
  #include&lt;sstream&gt;
  #include&lt;cmath&gt;
  #include&lt;cstdlib&gt;
  #include&lt;string&gt;
  #include&lt;list&gt;
  #include &lt;forward_list&gt;
  #include&lt;vector&gt;
  #include&lt;unordered_map&gt;
  #include&lt;algorithm&gt;
  #include &lt;array&gt;
  #include &lt;regex&gt;
  #include&lt;random&gt;
  #include&lt;stdexcept&gt;
  
  //------------------------------------------------------------------------------
  
  
  //------------------------------------------------------------------------------
  
  typedef long Unicode;
  
  //------------------------------------------------------------------------------
  
  using namespace std;
  
  template&lt;class T&gt; string to_string(const T&amp; t)
  {
      ostringstream os;
      os &lt;&lt; t;
      return os.str();
  }
  
  struct Range_error : out_of_range { // enhanced vector range error reporting
      int index;
      Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i) { }
  };
  
  
  // trivially range-checked vector (no iterator checking):
  template&lt; class T&gt; struct Vector : public std::vector&lt;T&gt; {
      using size_type = typename std::vector&lt;T&gt;::size_type;
  
  #ifdef _MSC_VER
      // microsoft doesn't yet support C++11 inheriting constructors
      Vector() { }
      explicit Vector(size_type n) :std::vector&lt;T&gt;(n) {}
      Vector(size_type n, const T&amp; v) :std::vector&lt;T&gt;(n,v) {}
      template &lt;class I&gt;
      Vector(I first, I last) : std::vector&lt;T&gt;(first, last) {}
      Vector(initializer_list&lt;T&gt; list) : std::vector&lt;T&gt;(list) {}
  #else
      using std::vector&lt;T&gt;::vector;   // inheriting constructor
  #endif
  
      T&amp; operator[](unsigned int i) // rather than return at(i);
      {
          if (i&lt;0||this-&gt;size()&lt;=i) throw Range_error(i);
          return std::vector&lt;T&gt;::operator[](i);
      }
      const T&amp; operator[](unsigned int i) const
      {
          if (i&lt;0||this-&gt;size()&lt;=i) throw Range_error(i);
          return std::vector&lt;T&gt;::operator[](i);
      }
  };
  
  // disgusting macro hack to get a range checked vector:
  #define vector Vector
  
  // trivially range-checked string (no iterator checking):
  struct String : std::string {
      using size_type = std::string::size_type;
  //  using string::string;
  
      char&amp; operator[](unsigned int i) // rather than return at(i);
      {
          if (i&lt;0||size()&lt;=i) throw Range_error(i);
          return std::string::operator[](i);
      }
  
      const char&amp; operator[](unsigned int i) const
      {
          if (i&lt;0||size()&lt;=i) throw Range_error(i);
          return std::string::operator[](i);
      }
  };
  
  
  namespace std {
  
      template&lt;&gt; struct hash&lt;String&gt;
      {
          size_t operator()(const String&amp; s) const
          {
              return hash&lt;std::string&gt;()(s);
          }
      };
  
  } // of namespace std
  
  
  struct Exit : runtime_error {
      Exit(): runtime_error("Exit") {}
  };
  
  // error() simply disguises throws:
  inline void error(const string&amp; s)
  {
      throw runtime_error(s);
  }
  
  inline void error(const string&amp; s, const string&amp; s2)
  {
      error(s+s2);
  }
  
  inline void error(const string&amp; s, int i)
  {
      ostringstream os;
      os &lt;&lt; s &lt;&lt;": " &lt;&lt; i;
      error(os.str());
  }
  
  
  template&lt;class T&gt; char* as_bytes(T&amp; i)  // needed for binary I/O
  {
      void* addr = &amp;i;    // get the address of the first byte
                          // of memory used to store the object
      return static_cast&lt;char*&gt;(addr); // treat that memory as bytes
  }
  
  
  inline void keep_window_open()
  {
      cin.clear();
      cout &lt;&lt; "Please enter a character to exit\n";
      char ch;
      cin &gt;&gt; ch;
      return;
  }
  
  inline void keep_window_open(string s)
  {
      if (s=="") return;
      cin.clear();
      cin.ignore(120,'\n');
      for (;;) {
          cout &lt;&lt; "Please enter " &lt;&lt; s &lt;&lt; " to exit\n";
          string ss;
          while (cin &gt;&gt; ss &amp;&amp; ss!=s)
              cout &lt;&lt; "Please enter " &lt;&lt; s &lt;&lt; " to exit\n";
          return;
      }
  }
  
  
  
  // error function to be used (only) until error() is introduced in Chapter 5:
  inline void simple_error(string s)  // write ``error: s and exit program
  {
      cerr &lt;&lt; "error: " &lt;&lt; s &lt;&lt; '\n';
      keep_window_open();     // for some Windows environments
      exit(1);
  }
  
  // make std::min() and std::max() accessible on systems with antisocial macros:
  #undef min
  #undef max
  
  
  // run-time checked narrowing cast (type conversion). See ???.
  template&lt;class R, class A&gt; R narrow_cast(const A&amp; a)
  {
      R r = R(a);
      if (A(r)!=a) error(string("info loss"));
      return r;
  }
  
  // random number generators. See 24.7.
  
  
  
  inline int randint(int min, int max) { static default_random_engine ran; return uniform_int_distribution&lt;&gt;{min, max}(ran); }
  
  inline int randint(int max) { return randint(0, max); }
  
  //inline double sqrt(int x) { return sqrt(double(x)); } // to match C++0x
  
  // container algorithms. See 21.9.
  
  template&lt;typename C&gt;
  using Value_type = typename C::value_type;
  
  template&lt;typename C&gt;
  using Iterator = typename C::iterator;
  
  template&lt;typename C&gt;
      // requires Container&lt;C&gt;()
  void sort(C&amp; c)
  {
      std::sort(c.begin(), c.end());
  }
  
  template&lt;typename C, typename Pred&gt;
  // requires Container&lt;C&gt;() &amp;&amp; Binary_Predicate&lt;Value_type&lt;C&gt;&gt;()
  void sort(C&amp; c, Pred p)
  {
      std::sort(c.begin(), c.end(), p);
  }
  
  template&lt;typename C, typename Val&gt;
      // requires Container&lt;C&gt;() &amp;&amp; Equality_comparable&lt;C,Val&gt;()
  Iterator&lt;C&gt; find(C&amp; c, Val v)
  {
      return std::find(c.begin(), c.end(), v);
  }
  
  template&lt;typename C, typename Pred&gt;
  // requires Container&lt;C&gt;() &amp;&amp; Predicate&lt;Pred,Value_type&lt;C&gt;&gt;()
  Iterator&lt;C&gt; find_if(C&amp; c, Pred p)
  {
      return std::find_if(c.begin(), c.end(), p);
  }
  
  #endif //H112
  </code></pre>
  
  <p>Thanks in advance for your help!
  PS: If you believe I should start with another book because I might encounter more problems like this one, please let me know :)</p>