Windows下编译C代码添加调试符号失败:gdb-oneapi提示无符号
Windows下Intel编译器编译C代码后,gdb-oneapi无法识别调试符号
在Windows系统下使用Intel的icl.exe或icx.exe编译C代码,已生成testmain.exe、.ilk和.pdb文件,但运行gdb-oneapi testmain.exe时,始终提示No debugging symbols found in <exe>。
测试代码
#include <stdio.h> #include <stdlib.h> int main() { printf("Hello world!\n"); return EXIT_SUCCESS; }
尝试过的编译命令
icl.exe main.c /debug -o testmain.exe icl.exe main.c /debug /Z7 -o testmain.exe icx.exe main.c /debug /Z7 -o testmain.exe icl.exe main.c /debug /Zi -o testmain.exe
调试命令
gdb-oneapi testmain.exe
解决建议
- 确认gdb-oneapi版本与Intel编译器版本匹配,版本不兼容会导致无法读取PDB格式的调试符号
- 编译时使用
/debug:full替代/debug,明确生成完整的调试信息 - 在gdb-oneapi中手动加载PDB符号:启动调试后执行
symbol-file testmain.pdb,强制指定符号文件路径 - 检查编译命令是否包含优化参数(如
/O系列),优化会剥离调试符号,确保编译时未添加任何优化选项 - 使用
icx.exe编译时,尝试组合/Z7与/debug:pdb参数,明确将调试符号写入PDB文件
内容的提问来源于stack exchange,提问作者DJames
相关产品推荐
相关产品推荐

