[omniORB] Repost: Why this call failed in dll?
Sai-Lai Lo
S.Lo@orl.co.uk
27 Oct 1998 10:41:51 +0000
I think the problem is that you have not qualified "extern ServiceClass
Service" with a __declspec(dllimport) when your application code is
compiled. In omniORB2 all global variables in the DLLs that have to be
accessed in the application code are prefixed with the macro
_OMNIORB_NTDLL_IMPORT which translate into __declspec(dllimport) when the
header files are included in the application code.
Don't just take my word for it. Please read up on the MSVC++ dllimport
crap..
Regards,
Sai-Lai
>>>>> Bing Zhang writes:
> I have a very simple class in file services.h:
> class ServiceClass {
> unsigned long caminStartTime;
> public:
> ServiceClass();
> resetStartTime(unsigned long delta);
> unsigned long currentTime();
> };
> extern ServiceClass Service;
> In file service.cc,
> ServiceClass::ServiceClass() {
> caminStartTime = (unsigned long) timeGetTime();
> }
> ServiceClass::resetStartTime(unsigned long delta) {
> caminStartTime = delta;
> }
> unsigned long ServiceClass::currentTime() {
> return (unsinged long) timeGetTime();
> }
> ServiceClass Service;
> In my main(), I call
> Service.resetStartTime(0);
> This works fine if I compile my main, application codes and omniORB2
> source code (I modified some part of omniORB codes to suit our
> situation) together with service.cc.
> But when I put the service.cc along with omniORB source code in a dll
> and link my application code to this
> dll, every time this call is made, it throws out a "The instruction at
> xxxxxx reference memory at xxxxxxx. The memory can not be wrriten" error
> when the statement
> caminStartTime = delta;
> is executed. But the call Service.currentTime() runs ok. So I think the
> system does not want me to modify the member variable of Service, which
> is
> now a global variable inside the dll.
> I am using vc++ 5.0 and omniORB 2.4. I built the dll by adding my source
> codes to the dir.mk of omniORB.
> What is wrong?
--
Dr. Sai-Lai Lo | Research Scientist
|
E-mail: S.Lo@orl.co.uk | Olivetti & Oracle Research Lab
| 24a Trumpington Street
Tel: +44 223 343000 | Cambridge CB2 1QA
Fax: +44 223 313542 | ENGLAND