Can Visual Studio optimize precompiled code?

Well, the best way to explain my question are two examples:

Example 1:

You created yourself a framework or engine of some kind MyLibrary, and you created it as a .lib with maximum optimization parameters. Now you include the headers and link . lib in the new MyImplementation project. The project uses most of the functions of MyLibrary, and when you are done, you create the project (again with maximum optimization).

Example 2:

Again, you have the same library, but instead of creating it, you will leave it open with the source code . Then you create the same MyProject that includes the headers, and you create MyProject with maximum optimization.

So, will Example 2 work faster since the compiler has access to the entire source code (framework / engine + project in which you use it)?

+4
source share
1 answer

The static library is precompiled, which means that any further optimization depends on the linker. These days there is a big performance gain that can be obtained from the linker, but in general, the best results come from optimization using the profile, which requires special compiler settings to load the profile. It is always advisable to have an open source project (if you are not protecting intellectual property), because then developers can compile the project for their platform and compiler, not to mention that debugging is almost impossible without source code.

+2
source

Source: https://habr.com/ru/post/1443883/


All Articles