[omniORB] Warnings when linking to omniORB statically on windows

Glen Walker Glen.Walker@brookers.co.nz
Sun Mar 23 21:22:02 2003


This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain;
	charset="iso-8859-1"

Hi,

When linking to omniORB 4.0.1 statically on Windows I get the following
linker warnings:

LINK : warning LNK4049: locally defined symbol ""int __cdecl strcasecmp(char
const *,char const *)" (?strcasecmp@@YAHPBD0@Z)" imported
LINK : warning LNK4049: locally defined symbol ""int __cdecl
strncasecmp(char const *,char const *,unsigned int)"
(?strncasecmp@@YAHPBD0I@Z)" imported

The final executable then exports these symbols.

I found references to this warning in the mailing list archive at
http://www.omniorb-support.com/pipermail/omniorb-list/2002-June/021097.html
and
http://www.omniorb-support.com/pipermail/omniorb-list/2002-September/021765.
html but no explanation of how to fix it. Anyway, even though this is all
pretty harmless, I don't like linker warnings or executables that export
symbols for random functions, so I did a little digging. What I found is
that the static libraries (omniORB4.lib and omniORB4d.lib at least) export
these symbols because of what looks to me like an error in the header file
include/omniORB4/internal/libcWrapper.h

According to include/omniORB4/CORBA_sysdep.h : 
// _OMNIORB_LIBRARY         is defined when the omniORB library is compiled.
// _OMNIORB_DYNAMIC_LIBRARY is defined when the dynamic library is compiled.
// _WINSTATIC               is defined when an application is compiled to
use the static library

The current version of libcWrapper.h exports strcasecmp and strncasecmp if
_OMNIORB_LIBRARY is defined, which is incorrect, since you don't want the
static library to export anything.

If I change the following lines in libcWrapper.h :

#if defined(_MSC_VER)
#  if defined(_OMNIORB_LIBRARY)
#    define _NT_DLL_ATTR __declspec(dllexport)
#  else
#    define _NT_DLL_ATTR __declspec(dllimport)
#  endif
#else
#  define _NT_DLL_ATTR
#endif

to

#if defined(_MSC_VER)
#  if defined(_OMNIORB_DYNAMIC_LIBRARY)
#    define _NT_DLL_ATTR __declspec(dllexport)
#  elif !defined(_WINSTATIC)
#    define _NT_DLL_ATTR __declspec(dllimport)
#  elif defined(_OMNIORB_LIBRARY)
#    define _NT_DLL_ATTR
#  else
#    define _NT_DLL_ATTR
#  endif
#else
#  define _NT_DLL_ATTR
#endif

and then recompile omniORB, the linker warnings when using the static
libraries go away, and the extra symbols are no longer exported, which makes
me happy.

Duncan, could you check my changes to make sure they are correct, and if so
update CVS. Keep up the good work.

Thanks,
Glen

--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain;
	name="InterScan_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="InterScan_Disclaimer.txt"

========================================================================
WARNING- This e-mail including any attachments, is for the 
personal use of the recipient(s) only.
Republication and re-dissemination, including posting to news
groups or web pages, is strictly prohibited without the express
prior consent of Thomson legal & Regulatory Limited
ABN 64 058 914 668
=====================================================================

--------------InterScan_NT_MIME_Boundary--