views:

186

answers:

5

I just added STL usage to some code, and I'm getting this link error:

error LNK2019: unresolved external symbol "public: __thiscall std::_Lockit::~_Lockit(void)"

I must be missing something in the link, I've done this before - and googling has not helped so far. hmm......

Here's the code snippet:

#pragma once
#include "Observer.h"
#include <list>

class NGE_Observable
{
public:
    Observable(void);
    virtual ~Observable(void);
    void    RegisterObserver(Observer *pObserver, void *user);
    void    UnRegisterObserver(Observer *pObserver);
    void    NotifyObservers();

private:
    std::list<Observer *>    observers;
};

Answered!: Operator error - duh. I had set the project properties to ignore all default libraries, so the stl library was not being linked. I was confused since I only got one error message, but as I added stl calls, the link errors increased.

A: 

One possible reason is that you declared your destructor for class _Lockit, but you didn't implement it.

Is _Lockit implemented by you?

LATER EDIT: Does this help you?

Cătălin Pitiș
No - this was included automatically when I included <list>
Jeff
Now I see that you've mentioned std::_Lockit
Cătălin Pitiș
thanks - my stdafx.h already has the "#define WIN32_LEAN_AND_MEAN", but I think you are on the right track
Jeff
It is hard to give an answer without having the full context (project setup, significant header files) in front of me :). At least I hope I really put you on the right track.
Cătălin Pitiș
Oh... and I forgot. Sometimes, when out of ideas, a full rebuild might work...
Cătălin Pitiș
A: 

Maybe you have your have the compiler options set to multi-threading while the linker tries to link to a single-threaded standard library. Inconsistency in the threading model or threading related #defines are often the reason for problems in classes that have "lock" in the name...

sth
VS2005 doesn't allow single threaded C(++) library anymore. Only multithreaded library
Cătălin Pitiș
A: 

If possible post your code. Also take a look at this seemingly related issue on MSDN forums. Are you using any old-style headers etc?

dirkgently
A: 

Is the destructor actually implemented anywhere? If not, that's your problem. The list tries to call the destructor on contained elements when they're deleted, and if the destructor doesn't actually exist anywhere, you get a linker error.

jalf
A: 

The error clears says: std::_Lockit is declared but NOT defined.

Please post the definition of "std::_Lockit" if you implemented it. If somebody else implmented it, then you forgot to link the library file but just include the header file.

J.W.
Thanks - this the STL library that ships with VS2005, so I think it should be linked automatically? Also note this is the only link error, so the other calls must have linked correctly. I think you are on the right track, some link subtlety I am missing
Jeff