VC++ not linking my lib correctly

G

George Faraj

Hi, I have a .lib project and a WIN32 .exe project to test the
library. When I'm trying to debug this application, I see that the
debugger displays incorrect values to some variables. This causes
runtime errors in my code. Sometimes this happens, sometimes it
doesn't. I searched the Microsoft Knowledge Base and saw this article:

http://support.microsoft.com/default.aspx?scid=kb;en-
us;100773&Product=vcNET

But both of those projects have optimizations off. I am
clueless on how to solve this problem now.

More specifically, I see that this happens only to class member
variables, and not to function local variables.

Another thing I see (and which causes the runtime error I'm having) is
that class members that are vectors are messed up. After creating my
class, I check my vector's size using size() and it returns -13172,
and I call empty() and it returns false. It should be empty at this
time. The error occurs in the following code:

YControl* YContainer::GetFocusedControl()
{
if (!Controls.empty())
return Controls.back();

return 0;
}

Since empty() returns false, it calls back() and somewhere it goes
wrong and throws an access violation exception. This happens on a
Release version of the library and application too.

This is really weird. Anyone know what could be wrong?

I appreciate any help.

Thanks,
George Faraj
 
M

Martijn Lievaart

Hi, I have a .lib project and a WIN32 .exe project to test the
library. When I'm trying to debug this application, I see that the
debugger displays incorrect values to some variables. This causes
runtime errors in my code. Sometimes this happens, sometimes it
doesn't. I searched the Microsoft Knowledge Base and saw this article:

Your question is off topic for this group, you'll probably get better
answers in a group for your compiler.

That said, you may want to try to rebuild from scratch, check that you
don't use different headers in the lib as in the application, and/or turn
of precompiled headers.

HTH,
M4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top