AlainD
AlainD

Reputation: 6607

Prevent temporary object files hitting disk in MSVC

Say I have a CPP file called test.cpp. On Ubuntu using gcc 9.3.0 I can use these commands:

The last option is great since no intermediate object files remain after compilation. (I'm unsure whether gcc is doing everything in-memory, or whether object files are temporarily hitting disk before being cleaned up during linking).

On Windows, cl test.cpp /link /out:test.exe creates the executable test.exe, but also the object file test.obj.

Is there a way to prevent MSVC from creating the intermediate object files? Alternatively, is there a link option to ask MSVC to clean up?

Upvotes: 1

Views: 664

Answers (1)

Botje
Botje

Reputation: 30840

No. The best you can do is use the /Fo flag to dump the .obj file under %TMPDIR% or so.

Don't do this for large builds, as foo/Bar.cpp and qux/Bar.cpp will map to Bar.obj and give you very interesting compilation/linking errors.

Upvotes: 1

Related Questions