I am in a situation where I need to synchronize two threads in two different dll modules synchronize around the same CCriticalSection object. I can define the CCriticalSection in one module but how can ther module access it?

I would need to place the following call in corresonding function in each thread.

Code:
CSingleLock lock( &theCriticalSection, TRUE);
I tried using this approach but no luck. I tested with a simple int variable but it doesn't recognize it in the other dll (although it buids).

Code:
#pragma data_seg("shared")
__declspec(dllexport) CCriticalSection theCriticalSection;
__declspec(dllexport) int number = 7;
#pragma data_seg()
#pragma comment(linker, "/section:shared,RWS")
I declare this as following in the dll where I want to use it:

__declspec(dllimport) CCriticalSection theCriticalSection;
__declspec(dllimport) int number;

Later in the function TRACE("number = %s", number ); asserts because it can't apparently link/recognize to `number`variable.