No debugging symbols found in Visual Studio when built C program with Bazel(Windows)

64 views
Skip to first unread message

Uma Patil

unread,
Oct 20, 2022, 8:02:05 PM10/20/22
to bazel-discuss

I have simple C program. I want to build and debug C program using Bazel on Windows within Visual Studio Code . But getting error as: (No debugging symbols found in bazel-bin/examples/application/application). How can I get Symbols.

 I have cc_binary :

cc_bin`enter code here`ary( name = "main", srcs = glob(["*.c"]), deps = [ "//examples/sub_main", ], visibility = ["//visibility:public"], )

I'm using following command to build and debug.

bazel build --compilation_mode=dbg //examples/main --strip=never 

gdb bazel-bin/examples/main/main 

But I'm getting error as: (No debugging symbols found in bazel-bin/examples/application/application) Even after using compilation_mode ad dbg why is it not generating any Symbols? How can I get symbols to debug?

Am I missing something here? Please let me know

zhang kai

unread,
Nov 10, 2022, 6:42:16 AM11/10/22
to bazel-discuss
Have you tried manually adding --copt=/Z7?

Konstantin

unread,
Nov 12, 2022, 5:56:15 PM11/12/22
to bazel-discuss
If you use 
     load("@rules_cc//cc:defs.bzl", "cc_binary")
like in this example on Windows, then it definitely uses `/Z7` flag (see here). 
I just tried it to be sure and the binary I got does contain debug symbols.
You can use Bazel command line flag `--subcommands=pretty_print` to see which exactly options it uses on the compiler command line.

Konstantin

Uma Patil

unread,
Nov 15, 2022, 1:10:45 PM11/15/22
to bazel-discuss
Hi Konstantin,

Thank you for your response. In my case I had "build --incompatible_enable_cc_toolchain_resolution" in my .bazelrc file. I'm not sure exactly, but when i removed this it was generating debugging symbols. Let me know if you have any idea why was --incompatible... flag causing issue to create sybols.
Reply all
Reply to author
Forward
0 new messages