I am getting error Error C1007 unrecognized flag '-Ot' in 'p2' but unable to find -Ot in the command line string of the project. Googling did not help. Anyone know what does that flag stand for ?
4 Answers
I had a similar issue on a project that I was compiling. It seems to be caused when MSVC 2017 linker tries to link a dependency library ".lib" to your project and it was compiled with Optimization flag /Ot
enabled. That is why you can not see it on command line of your own project. You can try one of these actions.
- Recompile your libs without
/Ot
enabled (Properties → C/C++ → Optimization → Favor Size or Speed → Neither), then recompile whole project. - Update MSVC 2017 toolchain to the latest one, which should be 14.14.26428. After updating, recompile your project. It is strange, but in my machine configuration, toolchain 14.13 couldn't link libraries compiled with newer toolchains and
/Ot
enabled.
Both solutions worked in my case, but I ended up using number 2.
-
I have the same problem, using 14.15 tools – Oswin Sep 03 '18 at 06:34
-
Didn´t use 14.15 yet. Try to make sure your dependency libraries are also compiled with 14.15. – txicos Sep 04 '18 at 11:30
Just for future reference to this error msg: I got this error with no -Ot option set, the error message was misleading. Turned out that I tried to build a project with a 140 toolset (VS2015 - forgot to upgrade to 141) with .dll and .lib dependencies already built with 141 (VS2017). After updating the toolset to 141 the project could be built.

- 4,514
- 2
- 31
- 33
You should find this flag in the Optimization property page of your project.
-Ot (/Ot) option is the Favor Fast Code flag (Attempts to offer improvements in execution time over space)
According to the Microsoft Visual C++ Documentation (https://learn.microsoft.com/en-us/cpp/build/reference/os-ot-favor-small-code-favor-fast-code),
If you use /Os or /Ot, then you must also specify /Og to optimize the code.

- 781
- 5
- 9
Happened to me while building nmap. Executables did not have /GL, while libnetutil did. Removing /GL from libnetutil fixed it. Or, if possible (and desired), align /GL to all dependent targets (lib, dll/exe).

- 160
- 1
- 8