I'm compiling a very simple C program with two source files.
File 1:
#include <stdio.h>
#include "conv.h"
/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300 */
int main()
{
int fahr;
float celsius;
int lower, upper, step;
lower = 0; /* lower limit of temperature table */
upper = 300; /* upper limit */
step = 20; /* step size */
fahr = lower;
while (fahr <= upper) {
celsius = f2c(fahr);
printf("%d%0.2f
", fahr, celsius);
fahr = fahr + step;
}
return 0;
}
File 2:
#include "conv.h"
/* Convert Fahrenheit to Celsius */
float f2c(int fahr) {
float celsius;
celsius = (fahr-32) * (5.0 / 9.0);
return celsius;
}
/* Convert Celsius to Fahrenheit */
float c2f(int cel) {
float fahr;
fahr = cel * (9.0 / 5.0) + 32;
return fahr;
}
I'm 'debugging' the program in windbg, although the program runs fine -- it's for experimentation. I'm compiling using the command-line Developer Command Prompt for VS 2019 in two ways. In the first case, I run the whole thing through CL:
cl /Zi /Fd:fahr fahr.c conv.c
and in the second case, I'm compiling without linking, then linking the object files:
cl /c fahr.c conv.c
cl /Zi /Fd:fahr fahr.obj conv.obj
In the first case, I can debug in windbg just fine. I open the executable, set a breakpoint, run it, and up comes my source file. But when I compile the second way, windbg will no longer connect to my source, and it fails to find variables in fahr.c and conv.c. As far as I can tell, everything is the same except for the circumstances when I link. What am I missing?
question from:
https://stackoverflow.com/questions/66054850/why-is-my-pdb-file-missing-symbols-when-i-link-object-files 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…