2

I had to use a preprocessor, so I changed:

Configuration Properties -> C++ -> Preprocessor -> Preprocess to a
File -> Yes

And got the error:

Error 1 error LNK1104: cannot open file 'Debug\asnreal.obj'

The solution to this problem:

I had to add quotes around the path to my .lib file in
Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies .

I do not understand what kind of file .lib? Where is it? In my project, it is not. What do I need to specify in Additional Dependencies? I tried to add the path to debug my project in quotation marks, but nothing happens.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tipok
  • 675
  • 8
  • 26

1 Answers1

2

The compiler outputs either the .obj file or the preprocessed file. When you enable the preprocessor output you effectively disable the output of the .obj file.

The VS doesn't take this in account and starts the linker anyway. Since you didn't output an .obj file the linker can't find it.

You can get much more in trouble when you have an old .obj file in place and changes in the source code generates new preprocessed output but don't get into the linked executable.

harper
  • 13,345
  • 8
  • 56
  • 105
  • 1
    Thanks. In a default VS2019 setup, the preprocessed files have the [i extension](https://stackoverflow.com/questions/28178790/which-file-is-generated-after-preprocessing-of-a-c-program). Added a request in the [form of a comment](https://developercommunity.visualstudio.com/comments/888419/view.html) so the jump link in the Error List directs to the relevant section in the description. – Laurie Stearn Jan 17 '20 at 08:26