title: gmon.out isn't created when I compile with -pg flag with g++
body: <p>I'm running on Mac OSX, version 10.8.5 (Mountain Lion). I have the following simple C++ code.</p>
  
  <p><strong><code>main.cpp</code></strong>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main ()
  {
      std::cout &lt;&lt; "Hello world!"&lt;&lt;std::endl;
      std::cout &lt;&lt; "Goodbye world!"&lt;&lt;std::endl;
      return 0;
  }
  </code></pre>
  
  <p>I'm trying to get gprof to work on my computer.  As the <a href="http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html#SEC2" rel="nofollow noreferrer">manual</a> suggests, I enter the following two lines into my terminal:</p>
  
  <pre><code>g++ -g -pg main.cpp -o a.out 
  ./a.out
  </code></pre>
  
  <p>However this does not generate a <code>gmon.out</code> file as it is supposed to.  When I try typing <code>gprof</code> in the terminal, it says:</p>
  
  <pre><code>gprof: can't open: gmon.out (No such file or directory)
  </code></pre>
  
  <p>which is to be expected since <code>gmon.out</code> isn't there...</p>
  
  <p>Any ideas on what I'm doing wrong?</p>
  
  <p>EDIT:  Some other things that may help: </p>
  
  <ul>
  <li><p>My friend, who has a similar OS X version (I can ask him later to confirm), and the exact same versions of <code>g++</code> and <code>gprof</code>, was able to
  use <code>gprof</code> successfully as I have outlined.</p></li>
  <li><p>I'm using an older version of <code>g++</code> but I have read online that updating to a newer version didn't help.</p></li>
  <li><p><code>a.out</code> works perfectly, it prints out <code>Hello world!</code> and <code>Goodbye world!</code>. I also tried this with a more complex C++ program with
  several classes and it still has the same problem.  Everything
  compiles and runs normally but no gmon.out file is produced.</p></li>
  </ul>