[Expat-discuss] Re: using expat as a static library

Nick Lehman nick@integrasolv.com
Thu Jul 4 20:25:03 2002


Hi,
I think the issue is the preprocessor tests for defining XMLPARSEAPI
in xmlparse.[ch] is always  __declspec(dllimport) type __cdecl on windows.
I think this produces dll mangled names thats why you get __imp__ stuff
prepended on the symbol names.  I hacked those definitions in my copy
of 1.95.3 so they looked like the unix definitions meaning just "type"
which is actually __cdecl unless your using /Gz(stdcall) /Gr(fastcall).
So the current windows code path builds dll mangled names no matter what.
So even though you think you've got a legit static link libary you don't.
And you don't find out until you link your application.  Anyhow the end
result is the current windows code path can only really build dll's because
the symbols are named something you're not expecting.  I haven't actually
thought throuh how to make a general fix but all I did to get my test to link
was:
in expat.h and xmlparse I changed the lines
#define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
to
#define XMLPARSEAPI(type) type

than you can remake xmlparse.obj xmltok.obj xmlrole.obj ...
and than use lib to make your .lib file

the tests to decide the definition of XMLPARSEAPI should be changed for
windows to figure out if _DLL is defined.  If it is than the __declspec
syntax is used otherwise not

I hope that helps get you over the hump.  Bear in mind I could be wrong
Nick

Nick Lehman
IntegraSolv Corp
http://www.integrasolv.com