Re: [xml] Dynamic Linkage And MSCC



Igor Zlatkovic wrote:

Am I missing something? How did you mean to get the .DEF file from an output
such as produced by 'cl /E'?


Hi Igor,

As Peter suggests, use the compiler Luke! What you need is
a "pre .DEF" file like this:

LIBRARY LIBXML2
EXPORTS
#include "..\..\include\libxml\xmlversion.h"
#ifdef LIBXML_HTML_ENABLED
        htmlInitAutoClose
#endif

Put that into a file called libxml2_so.def.proto in the same directory
as
the .DSP file.  Then add it to the list of source files.  Visual C++
will
(correctly) decide that it doesn't know what to do with it but you can
add
a custom build step (Project, Settings, select the file in the
window...).
To preprocess the file add the following:

     cl /EP $(InputPath) > libxml2_so.def

and set the "Outputs" to libxml2_so.def.  You can also add a dependency
on ..\..\include\libxml\xmlversion.h which means the .DEF file is
rebuilt
when you change the version header.

Then add libxml2_so.def to the project - the name identifies it as _the_
.DEF file for the libxml2_so project & it will be used by the linker.

Note  - you need /EP to remove #line directives which the linker isn't
expecting (!).  The only problem seems to be the presence of code ie.

extern void xmlCheckVersion(int version);

in the version control header.  This causes the linker to barf  - some
conditional compiles in the version header would cure this though.


Having said that, I'd prefer the exports to be managed without a .DEF
file!

Using something like the LIBXML_DLL_IMPORT method, although I would tend
to
call such symbols xxxx_DECLSPEC (sometimes it's import, sometimes it's
export)

/*
 * If no option specified in the build and we're on WIN32 then
 * import the symbols (minimal impact on users of the library).
 * If no definition is specified remove the symbol.
 */
#ifndef LIBXML_DECLSPEC
#ifdef WIN32
#define LIBXML_DECLSPEC __declspec(dllimport)
#endif
#endif
#ifndef LIBXML_DECLSPEC
#define LIBXML_DECLSPEC
#endif

As at present, its then the library responsibility to do a definition
-DLIBXML_DECLSPEC=__declspec(dllexport) in the distributed sources.


Nick




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]