"Whole program optimization" results in LNK1171 error - cannot find "c2.dll"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be loaded. The error contains the correct path to c2.dll (and it is definately there).

This only happens on some projects and only when "whole program optimization" option is turned on. If i turn off this option, the problem goes away. I have other projects (in the same solution) and in other solutions, that work with the "whole program optimization" option turned on. Some of the projects that work are larger and some smaller than the projects that don't work, so it is not a size issue.

I have searched the newsgroups and the web and i could not find any solutions to this problem. (Although i did find other people reporting the same problem, eg in microsoft.public.dotnet.languages.vc newsgroup)

Is there any solution to this?

The version i'm using:
Microsoft Development Environment 2002 Version 7.0.9466
Microsoft .NET Framework 1.0 Version 1.0.3705

Thanks,
 
I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be loaded. The error contains the correct path to c2.dll (and it is definately there).
This only happens on some projects and only when "whole program optimization" option is turned on. If i turn off this option, the problem goes away.

Dmitry,

Do you have a small(ish) project that you can use to demonstrate this
problem?

Dave
 
Hi,

The smallest of the projects is around 1000 files, so i cannot demostrate this problem easily.

Nonetheless, i have found a solution to this - it seems to come from the order of libraries in the
Linker's "AdditionalDependencies" field. Changing the order in which libraries are linked to the
project seems to fix the problem.

Eg if your project links against libraries a.lib, b.lib, c.lib, d.lib etc, then AdditionalDependencies would
contain "a.lib b.lib c.lib d.lib". Moving a.lib to the end of the list (to form "b.lib c.lib d.lib a.lib") would
probably fix the problem. If not, try repeating with the next library ("c.lib d.lib a.lib b.lib") etc. Following
this algorithm has fixed all three of my projects that did not work before.

Regards,
Dmitry


----- David Lowndes wrote: -----
I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be loaded. The error contains the correct path to c2.dll (and it is definately there).

Dmitry,

Do you have a small(ish) project that you can use to demonstrate this
problem?

Dave
 
Changing the order in which libraries are linked to the
project seems to fix the problem.

I think that's just as worrying as having the error in the first
place. It'd be good to get a repro for this situation to MS in order
to get it seen to.

Dave
 
Back
Top