Laethnes - 2012-07-09

First, I apologize for my English.

Short problem description:
I have problem with SmartPtr in multi threaded application and I'm not sure what I'm doing wrong, because some symbols are missing during linking.

My environment:
- MS Windows XP, SP3
- compiler from MS Visual Studio 2008
- QtCreator IDE
- Loki version: 0.1.7

Loki linking:
I compile it separately as static library using solution file in source file downloaded from Loki home web page.

My goal:
I want to create SmartPtr of an object ("ReconstructResult" type) which would use reference counting thread-safe (so RefCounted is unusable).

How do I do this:
- I use typedef of pointer type:

#include <loki/SmartPtr.h>
#include <loki/Threads.h>
// ...
typedef Loki::SmartPtr<ReconstructResult,
                        > ReconstructResultPtr;

- I define global macro "LOKI_OBJECT_LEVEL_THREADING" (no value) for whole project (it's defined in project file, so there shouldn't be problems like defining this macro after including headers).

What's wrong:
- At first compiler was complaining about undefined atomic_mutex_. This I solved using patch  which I found thanks to  (btw. similar error is reported at ).
- After this patch the error was solved and code finally compiled.
- But another error appeared during linking:

ModelViewWidget.obj:-1: Chyba:LNK2001: unresolved external symbol "private: static struct _RTL_CRITICAL_SECTION Loki::ObjectLevelLockable<class Loki::RefCountedMTAdj<class Loki::ObjectLevelLockable,class Loki::Mutex>::RefCountedMT<class Laethnes::ReconstructResult *>,class Loki::Mutex>::atomic_mutex_" (?atomic_mutex_@?$ObjectLevelLockable@V?$RefCountedMT@PAVReconstructResult@Laethnes@@@?$RefCountedMTAdj@VObjectLevelLockable@Loki@@VMutex@2@@Loki@@VMutex@3@@Loki@@0U_RTL_CRITICAL_SECTION@@A)

- and similar (same error, different obj files - these which uses the pointer).
- I solved it by adding following code to "loki/Threads.h":

    template <class Host, class MutexPolicy>
    CRITICAL_SECTION ObjectLevelLockable<Host, MutexPolicy>::atomic_mutex_;
    template <class Host, class MutexPolicy>
    CRITICAL_SECTION ClassLevelLockable<Host, MutexPolicy>::atomic_mutex_;

My problem:
- My problem is that I couldn't find any similar error report on Internet which means that people who posted patch at  and  didn't encounter it. From this I conclude that I'm doing something wrong which causes this error. And I don't know what it is, so I ask you.
- Also I don't know if my patch is good; I'm not good in using templates, I know only basics, using typename and specialization.