title: How to get debugging symbols when compiling with clang on Windows
body: <p>I am having trouble getting the debugger to work properly when setting up clang on my Windows 10 machine. Compilation seems to work OK, at least for the simple "hello, world" program I tried. However, when I try to run the lldb or gdb debuggers on this test program (or any other program I tried), it does not recognize function names.  </p>
  
  <p>Here's my C program code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      puts("Hello, world!");
      return 0;
  }
  </code></pre>
  
  <p>Nothing too spectacular here, I know. I'm compiling with the following command:</p>
  
  <pre><code>&gt; clang -g -O0 hello.c -o hello.exe
  </code></pre>
  
  <p>I then try to run the debugger:</p>
  
  <pre><code>&gt; lldb hello
  (lldb) target create "hello"
  Current executable set to 'hello' (x86_64).
  (lldb) b main
  Breakpoint 1: no locations (pending).
  WARNING:  Unable to resolve breakpoint to any actual locations.
  (lldb) r
  Process 12156 launched: 'C:\Users\********\Projects\clang-test\hello.exe' (x86_64)
  Process 12156 exited with status = 0 (0x00000000)
  (lldb)
  </code></pre>
  
  <p>Apparently the symbol "main" was not recognized, and the program did not halt at the start of the "main" function but ran to completion (in a different console window, hence no program output here).</p>
  
  <p>How do I get debugging symbols to work? In a different stackoverflow answer I found that adding compiler options "-g -O0" should do the trick, but as you can see that does not solve the problem for me. I also found a different stackoverflow answer about how to set up debugging if the code is not in the same directory as the executable, but that is not relevant to my case: the current working directory is the same as the directory with the code and executable in them.</p>
  
  <p>Some version information:</p>
  
  <pre><code>&gt; clang --version
  clang version 9.0.0 (tags/RELEASE_900/final)
  Target: x86_64-pc-windows-msvc
  Thread model: posix
  InstalledDir: C:\Program Files\LLVM\bin
  
  &gt; lldb --version
  lldb version 9.0.0
  </code></pre>