# Link time optimization flag not working for Visual Studio?

**URL:** <https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127>\
**Category:** The Projucer\
**Created:** [November 14, 2017, 5:28pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127 "2017-11-14T17:28:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [November 14, 2017, 5:28pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/1 "2017-11-14T17:28:50Z")

</div>

I am trying to disable link time optimization for the release build in Projucer for Visual Studio in an audio plugin project but that doesn’t appear to be set in the generated Visual Studio project. Bug or user error?

---

<div class="post-metadata">

**Author:** ![broose](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/broose/32/3381_2.png) [@broose](https://forum.juce.com/u/broose)\
**Post date:** [November 14, 2017, 8:57pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/2 "2017-11-14T20:57:59Z")

</div>

depends on compiler, I believe. Disabling Link Time Optimization when using the Intel C++ compiler on Visual Studio 2015 does not actually disable my link time optimization. If I’m compiling with the native Visual C++ compiler, the link time optimization does in fact disable accordingly.

With a current project, I cannot compile the PROJECT\_SharedCode binary with Intel C++ compiler as it bloats the .lib object to 3GB.

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [November 14, 2017, 9:00pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/3 "2017-11-14T21:00:55Z")

</div>

I am using Visual Studio 2017 version 15.5.0 preview 3 here.

I can obviously manually set the whole program optimization/link time code generation off, but it’s royally annoying to do each time I’ve saved the project with Projucer, since the audio plugin solutions have the 3 separate projects etc…

---

<div class="post-metadata">

**Author:** ![broose](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/broose/32/3381_2.png) [@broose](https://forum.juce.com/u/broose)\
**Post date:** [November 14, 2017, 9:04pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/4 "2017-11-14T21:04:06Z")

</div>

sounds like a bug!

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [November 16, 2017, 4:52pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/5 "2017-11-16T16:52:39Z")

</div>

Yep, it was a bug in the Projucer. This should be fixed on the develop brach shortly.

---

<div class="post-metadata">

**Author:** ![tsenkov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tsenkov/32/3150_2.png) [@tsenkov](https://forum.juce.com/u/tsenkov)\
**Post date:** [January 19, 2018, 3:40pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/6 "2018-01-19T15:40:20Z")

</div>

I am guessing optimization was disabled by default, previously? I noticed my release build going way up but haven’t linked (no pun intended) it to link-time optimization before. (at the same time I upgraded my project to latest JUCE, I had added a bunch of static libraries for a dependency and I thought that was messing up with the build).

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 19, 2018, 3:52pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/7 "2018-01-19T15:52:23Z")

</div>

Yes. LTO can be very expensive.

---

<div class="post-metadata">

**Author:** ![tsenkov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tsenkov/32/3150_2.png) [@tsenkov](https://forum.juce.com/u/tsenkov)\
**Post date:** [January 19, 2018, 4:06pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/8 "2018-01-19T16:06:05Z")

</div>

@t0m is it worth it in your experience?  
Please feel free to send me to read something if you have a link to share. Thanks.

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 19, 2018, 4:09pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/9 "2018-01-19T16:09:43Z")

</div>

Unfortunately it depends on the structure of your app. If the linking between separate compilation units is low then it shouldn’t have much of an effect (this is one of the reasons that JUCE modules `#include` multiple .cpp files into one place - you get most of the benefits of LTO at a fraction of the cost).

To get a definitive answer you’ll have to measure.

---

<div class="post-metadata">

**Author:** ![tsenkov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tsenkov/32/3150_2.png) [@tsenkov](https://forum.juce.com/u/tsenkov)\
**Post date:** [January 19, 2018, 4:16pm UTC](https://forum.juce.com/t/link-time-optimization-flag-not-working-for-visual-studio/25127/10 "2018-01-19T16:16:12Z")

</div>

Makes sense. Thanks.
