title: How do I debug C++0x programs in MacPorts gcc 4.5?
body: <p>I have a simple c++ program I am trying to debug, but gdb cannot find the object file for the libraries (or no debug info is available), and it does not seem able to find the debug symbols for my executable either.</p>
  
  <p>I am on OSX 10.5.8, with macports, and I compile my code with</p>
  
  <blockquote>
    <p>g++-mp-4.5 -Wall -pedantic -std=c++0x -g -ggdb -I/opt/local/include -L/opt/local/lib -lgsl 
    -static-libstdc++ MCMC-simplex.cpp -o mcmc</p>
  </blockquote>
  
  <p>(there is only one file, and g++-mp-4.5 is the macports executable for gcc/g++ 4.5 )</p>
  
  <p>When I try running gdb on the resulting executable, I get many error messages (at startup) of the form</p>
  
  <blockquote>
    <p>warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_gcc45/work/build/i386-apple-darwin9/libgcc/trunctfdf2_s.o" - no debug information available for "../../../gcc-4.5.0/libgcc/../gcc/config/soft-fp/trunctfdf2.c".</p>
  </blockquote>
  
  <p>which to me indicates that macports has a bug during its build (it seems like gdb is looking for the object files in the temporary build directory).</p>
  
  <p>I should add that when I try to see my programs listing in gdb (the one provided by Apple), it tries to look for a random <code>.s</code> file in <code>/var/tmp</code>, which to me sounds like an assembler file.  That is why I say it does not seem able to find the debug symbols for my program either.</p>
  
  <p>When I try MacPorts gdb 7.1, I get</p>
  
  <blockquote>
    <p>warning: `/var/folders/Xa/XaqHO9PeEC8K-Nrd0L9xWk+++TM/-Tmp-//cc2IvFto.o': can't open to read symbols: No such file or directory.
    (no debugging symbols found)...done.</p>
  </blockquote>
  
  <p>and none of the many error messages that Apple's gdb gives out (although the end result is the same).</p>
  
  <p>Has anyone come across this problem, and came up with a solution?</p>