Monday, December 22, 2008

Resolving Error LNK2001: unresolved external symbol __imp__time

I don't know if this is a generic situation or not, but it has been frustrating to resolve. The scenario is that I'm building some C/C++ FLEXnet components and was having no fun on getting the Release build to compile and link. After much fiddling, I was able to resolve everything down to one link error:

Error LNK2001: unresolved external symbol __imp__time

After comparing the differences between Debug and Release settings, I ended up stumbling upon the "Whole Program Optimization" setting (Project, Properties, Configuration Properties, General).

In my case, the default for the Release build was set to: Use Link Time Code Generation -- seems reasonable. What isn't reasonable is how it leads to the above linker error. I still have no idea why it causes it, but changing it to No Whole Program Optimization solved the issue.

Note: using Visual Studio 2008, SP1

1 comment:

Anonymous said...

Thank you so much for posting this. Saved me hours!

Cheers,
JP