linker errors gone with a clean build

Hi

My lib is added under Visual Studio 2008's
Property Pages->Linker->Input->Additional Dependencies

and the path to the library is also added under Property Pages->Linker->General->Additional Library Directories.

However, the compiler cleanly compiles and gives linker errors alternatively. If I do a Clean and Rebuild , then it compiles cleanly and build. However, when rerun right after (same code), gives linking error saying it

error LNK2019: unresolved external symbol __imp__X referenced in function "public: void __thiscall Y......

Anyone had this alternating problem?
LuckyLucksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sarabandeCommented:
the issue depends on whether it builds the static library which is without errors or whether it builds an application or dll which uses the static library. in the latter case you get the unresolved externals.

if your own observations are different, the issue may differ if the build order of your multiple projects is not defined properly. if you right-click to the solution tree you could check what your current build order is. in any case the static library should build first, then the dll projects (if any), and finally the application (projects).

to change build order, you may right-click to a project in the solution tree and check all predecessor projects. don't define too much. it normally is sufficient to have a chain where each project beside of the first one has exactly one project where it is dependent on.

Sara
0
sarabandeCommented:
note, wrong build orders where project C was built prior to project B though C uses functions from B would result into errors like the ones you described.

in the first build (clean + build) you have undefined externals since B wasn't built and the (old) B library was deleted by clean. in the second build B library exists and C would build without errors now.

not, actually a build of C always would use old B library so if you make changes to B and build C after it, you still would call into the old B library.

Sara
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.