Title: Linking fails when Link Time Optimisation is enabled
Tags: c++;visual-studio;optimization;visual-studio-2013;lto
Question: I have a (large) wxWidgets project, that compiles smoothly also in higher optimisation levels.
Now I enabled Whole Program Optimisation (/GL) for building objects and Link Time Code Generation (/LTCG) in settings of this project. This leads to an unresolved external reference - a function of external wxWidgets libraries I link agains no longer can be found.
So is this a known bug in LTO of Visual Studio? Any ideas how to workaround it or what could cause this?
Thanks!
Comment: HelloWorld: yes, I'm sure because I did not switch over to a different configuration but changed these two options in my current one.

Comment: Optimisations can sometimes work in such a way that even projects that shouldn't link do successfully link. This is because such optimisations can sometimes prove a function is not called and therefore not need to pull in the library its referenced in and then later on if _that_ library which wasn't referenced had unresolved references you wouldn't get the issue. Changing optimisation levels obviously cna change this and so you can get unresolved references. Even though you've effectively increased optimisation level with LTO it may be that the said functions aren't getting pruned any more.

Comment: Basically go and check if the unresolved reference is truly needed (it probably is, its likely your setup is wrong rather than LTO being broken) and when you've fixed it put it down to being lucky it did originally link rather than broken that it didn't subsequently link

Comment: Are you sure you enabled the option in the same! configuration where the paths to the librar(y/ies) are setup correctly?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:10/05/15', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<c++><visual-studio><optimization><visual-studio-2013><lto>', 'Title': 'Linking fails when Link Time Optimisation is enabled', 'ViewCount': 96, 'id': 32944464, 'user_AboutMe': '', 'user_AccountId': 1158073.0, 'user_DisplayName': 'Elmi', 'user_Reputation': 5691.0, 'user_Views': 643.0, 'user_id': 1138160.0}}