My project is native C++. Visual Studio Community 2019, 16.11.20 on 64-bit Windows 10.

I can build the debug version with no error, but when I build the release version, I get

LINK : fatal error C1007: unrecognized flag '-Zc:nrvo' in 'p2'

There is no flag containing 'nrvo' anywhere in either the C++ or linker command line. It seems this option has to do with automatic elision.

This error did not occur with previous builds, which I believe used VS 16.9. I am not sure of this.

How can I get rid of this error? I don't care which options are in effect for elision, but I do need to be able to produce an executable.

To set nrvo, you can refer to the document :

Select the Configuration Properties > C/C++ > Command Line property page.

In Additional options, add /Zc:nrvo or /Zc:nrvo-. Choose OK or Apply to save your changes.

Will /Zc:nrvo- work?

Library incompatibility is likely the problem--I am going to test this first.

I am using both VS2022 and VS 2019, and for projects built under VS2022, the libraries must be compiled with 14.3 toolset. But VS2019 does not have that toolset available.

Is there some simple way of having both libraries available, short of creating separate projects?

Libraries built with a later toolset was the problem. I changed all the compiler toolsets back to v14.2 (from 14.3), rebuilt the libraries, and now the linker doesn't get any error.

The "guidance regarding binary compatibility" page was also useful.