[omniORB] Byte order inversion on NT/MSVC++

Dietmar May dcmay@object-workshops.com
Thu, 17 Dec 1998 05:36:48 -0500


Sai-Lai,

Thanks for the ideas. However, all of the compiler switches seem to be OK.
I've verified the items you suggested, but am still unable to run because of
the same problem.

> omni::myByteOrder is defined in omniORB261_rt.dll and it must have the
> __declspec(dllimport) attribute attached when your code is compiled.
> This is normally done by the CPP macro _OMNIORB_NTDLL_IMPORT (in
> CORBA_sysdep.h).

The __declspec(dllimport) attrib IS attached to omni::myByteOrder. From a
preprocessed file:

  static __declspec(dllimport) const _CORBA_Char myByteOrder;

> First thing to check is whether when your code is compiled,
> the CPP macro _OMNIORB_NTDLL_IMPORT is defined as
> __declspec(dllimport).
>
> I have a strong suspicion that you either:
>
>    1. Have not defined the three CPP macros that are *required*
>         -D__x86__ -D__NT__ -D__WIN32__
>
> or 2. Have -D_OMNIORB2_DLL defined (which should only be defined when
>       building the runtime)
>
> or 3. Have -D_WINSTATIC defined but still link with the DLL.

Compiler parameters (taken from makefile output, so this is exactly what's
being passed to the compiler) are:
/c /nologo /G6 /GR /GX /W4 /vmg /Zp4 /DNT /D_MT /DDOT /DWIN32 /MT /EP
/DOMNI_ORB /D__WIN32__ /D__x86__ /D__NT__ /D__OSVERSION__=4 /Od /DOLD_LIB
/Fd... /Fp... /YX /Zi /Zm350

/EP is only there because I preprocessed the file to check the
_OMNIORB_NTDLL_IMPORT value. Also, I typically compile with /MD instead of
/MT, to use the MS C runtime DLL instead of static link libraries.

I've also added #error statements bracketed with #ifdefs to verify that
_OMNIORB2_DLL and _WINSTATIC are NOT defined.

Of course I haven't checked every file, but the make uses the same base
macro for most parameters on all files. And to the best of my knowledge,
there are no conflicting #define's within our code.

> So it is best to check what the value of _OMNIORB_NTDLL_IMPORT is when
your
> code is compiled. If it is not __declspec(dllimport) then the
> end result is that all reference to omni::myByteOrder in your code/stub
> will be directed to a local copy rather than the DLL.

Since this all looks OK, any further suggestions would be greatly
appreciated.

Also, it seems from reading the comments in the header file that in order to
create stub DLLs on NT, the macro USE_stub_in_nt_dll needs to be defined
before the first include of CORBA.h. Are there any other requirements, and
is there any further documentation or examples for creating stubs than the
comment in CORBA_sysdeps.h?

Regards,
Dietmar