You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Yotam Ofek <se...@zahav.net.il> on 2005/06/05 22:32:45 UTC

Statically linking with Xerces.

How can I statically link Xerces to my program (specifically, a DLL)?
I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces .lib 
file in the list of library files for my project, but still Depends.exe 
shows me that my DLL uses the xerces-c_2_6.dll.
What did I do wrong? I remember it working a couple of days ago, but I 
changed a few settings here and there and now it's relying on the DLL to 
function!
Thanks in advance.


Re: Statically linking with Xerces.

Posted by Alberto Massari <am...@datadirect.com>.
At 20.41 07/06/2005 +0200, Yotam Ofek wrote:
[...]

>>Oh, I see. Thank you so much for your help so far, but something still 
>>isn't working.
>>I compiled a static library of Xerces just like you told me to, but when 
>>linking it to my own DLL, I get lots of errors and warnings.
>>I get about 28 warnings saying "locally defined symbol "........." imported".
>>I also get about 7 errors saying that "unresolved external symbol _errno".
>>Can you help me?
>Nevermind. I was able to get rid of the _errno errors which I caused 
>myself, and I have set the linker to ignore libcmt.lib.
>The "locally defined symbol" things are still there, but they are just 
>warnings, so compilation is successful even with them.
>But now all Xerces functions are exported from my DLL, which is an 
>"unintended feature" in my sense. Any way to disable this?
>Sorry for all the nuisance I'm being.

The symbols should stop being exported once you fix the 
PLATFORM_EXPORT/PLATFORM_IMPORT macro and recompile everything.

Alberto




Re: Statically linking with Xerces.

Posted by Yotam Ofek <se...@zahav.net.il>.
Yotam Ofek wrote:

> Alberto Massari wrote:
>
>> At 14.35 06/06/2005 +0200, Yotam Ofek wrote:
>>
>>> Alberto Massari wrote:
>>>
>>>> At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>>>>
>>>>> How can I statically link Xerces to my program (specifically, a DLL)?
>>>>> I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces 
>>>>> .lib file in the list of library files for my project, but still 
>>>>> Depends.exe shows me that my DLL uses the xerces-c_2_6.dll.
>>>>> What did I do wrong? I remember it working a couple of days ago, 
>>>>> but I changed a few settings here and there and now it's relying 
>>>>> on the DLL to function!
>>>>> Thanks in advance.
>>>>
>>>>
>>>>
>>>>
>>>> Xerces doesn't provide a makefile to build a static library for 
>>>> Visual C++ (it has one for Visual C++ 7.1 though). If you really 
>>>> need to have one, you should create a brand new library project, 
>>>> move all the files to the new project,  remove the .rc file and the 
>>>> Win32MsgLoader, add the InMemMsgLoader (also replacing the macro 
>>>> definition XML_USE_WIN32_MSGLOADER with the 
>>>> XML_USE_INMEM_MESSAGELOADER one)
>>>>
>>>> Alberto
>>>>
>>> I think you miss-understood me. Xerces _does_ provide means to 
>>> easily build static libraries in VC6.
>>> I already have a static library of Xerces built, but what was 
>>> baffling was how to link my program to that library without having 
>>> my program rely on the Xerces DLL.
>>> Any ideas?
>>
>>
>>
>> Just do what I wrote: the library you see as the product of the 
>> compilation of the .dsp that ships with Xerces is just a "stub" 
>> library that redirects the calls to the DLL.
>>
>> Alberto
>>
>>
> Oh, I see. Thank you so much for your help so far, but something still 
> isn't working.
> I compiled a static library of Xerces just like you told me to, but 
> when linking it to my own DLL, I get lots of errors and warnings.
> I get about 28 warnings saying "locally defined symbol "........." 
> imported".
> I also get about 7 errors saying that "unresolved external symbol 
> _errno".
> Can you help me?
>
Nevermind. I was able to get rid of the _errno errors which I caused 
myself, and I have set the linker to ignore libcmt.lib.
The "locally defined symbol" things are still there, but they are just 
warnings, so compilation is successful even with them.
But now all Xerces functions are exported from my DLL, which is an 
"unintended feature" in my sense. Any way to disable this?
Sorry for all the nuisance I'm being.

Re: Statically linking with Xerces.

Posted by Alberto Massari <am...@datadirect.com>.
Ops, you are right I forgot two things:
- define the macros PLATFORM_EXPORT and PLATFORM_IMPORT declared in 
VCPPDefs.hpp to an empty value (or declare the macro XERCES_STATIC_LIBRARY 
if you are using a more recent version of Xerces)
- change the compiler options to use /MT and /MTd instead of /MD and /MDd

Alberto

At 20.28 07/06/2005 +0200, Yotam Ofek wrote:
>Alberto Massari wrote:
>
>>At 14.35 06/06/2005 +0200, Yotam Ofek wrote:
>>
>>>Alberto Massari wrote:
>>>
>>>>At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>>>>
>>>>>How can I statically link Xerces to my program (specifically, a DLL)?
>>>>>I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces .lib 
>>>>>file in the list of library files for my project, but still 
>>>>>Depends.exe shows me that my DLL uses the xerces-c_2_6.dll.
>>>>>What did I do wrong? I remember it working a couple of days ago, but I 
>>>>>changed a few settings here and there and now it's relying on the DLL 
>>>>>to function!
>>>>>Thanks in advance.
>>>>
>>>>
>>>>
>>>>Xerces doesn't provide a makefile to build a static library for Visual 
>>>>C++ (it has one for Visual C++ 7.1 though). If you really need to have 
>>>>one, you should create a brand new library project, move all the files 
>>>>to the new project,  remove the .rc file and the Win32MsgLoader, add 
>>>>the InMemMsgLoader (also replacing the macro definition 
>>>>XML_USE_WIN32_MSGLOADER with the XML_USE_INMEM_MESSAGELOADER one)
>>>>
>>>>Alberto
>>>I think you miss-understood me. Xerces _does_ provide means to easily 
>>>build static libraries in VC6.
>>>I already have a static library of Xerces built, but what was baffling 
>>>was how to link my program to that library without having my program 
>>>rely on the Xerces DLL.
>>>Any ideas?
>>
>>
>>Just do what I wrote: the library you see as the product of the 
>>compilation of the .dsp that ships with Xerces is just a "stub" library 
>>that redirects the calls to the DLL.
>>
>>Alberto
>>
>Oh, I see. Thank you so much for your help so far, but something still 
>isn't working.
>I compiled a static library of Xerces just like you told me to, but when 
>linking it to my own DLL, I get lots of errors and warnings.
>I get about 28 warnings saying "locally defined symbol "........." imported".
>I also get about 7 errors saying that "unresolved external symbol _errno".
>Can you help me?



Re: Statically linking with Xerces.

Posted by Yotam Ofek <se...@zahav.net.il>.
Alberto Massari wrote:

> At 14.35 06/06/2005 +0200, Yotam Ofek wrote:
>
>> Alberto Massari wrote:
>>
>>> At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>>>
>>>> How can I statically link Xerces to my program (specifically, a DLL)?
>>>> I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces 
>>>> .lib file in the list of library files for my project, but still 
>>>> Depends.exe shows me that my DLL uses the xerces-c_2_6.dll.
>>>> What did I do wrong? I remember it working a couple of days ago, 
>>>> but I changed a few settings here and there and now it's relying on 
>>>> the DLL to function!
>>>> Thanks in advance.
>>>
>>>
>>>
>>> Xerces doesn't provide a makefile to build a static library for 
>>> Visual C++ (it has one for Visual C++ 7.1 though). If you really 
>>> need to have one, you should create a brand new library project, 
>>> move all the files to the new project,  remove the .rc file and the 
>>> Win32MsgLoader, add the InMemMsgLoader (also replacing the macro 
>>> definition XML_USE_WIN32_MSGLOADER with the 
>>> XML_USE_INMEM_MESSAGELOADER one)
>>>
>>> Alberto
>>>
>> I think you miss-understood me. Xerces _does_ provide means to easily 
>> build static libraries in VC6.
>> I already have a static library of Xerces built, but what was 
>> baffling was how to link my program to that library without having my 
>> program rely on the Xerces DLL.
>> Any ideas?
>
>
> Just do what I wrote: the library you see as the product of the 
> compilation of the .dsp that ships with Xerces is just a "stub" 
> library that redirects the calls to the DLL.
>
> Alberto
>
>
Oh, I see. Thank you so much for your help so far, but something still 
isn't working.
I compiled a static library of Xerces just like you told me to, but when 
linking it to my own DLL, I get lots of errors and warnings.
I get about 28 warnings saying "locally defined symbol "........." 
imported".
I also get about 7 errors saying that "unresolved external symbol _errno".
Can you help me?

Re: Statically linking with Xerces.

Posted by Alberto Massari <am...@datadirect.com>.
At 14.35 06/06/2005 +0200, Yotam Ofek wrote:
>Alberto Massari wrote:
>
>>At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>>
>>>How can I statically link Xerces to my program (specifically, a DLL)?
>>>I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces .lib 
>>>file in the list of library files for my project, but still Depends.exe 
>>>shows me that my DLL uses the xerces-c_2_6.dll.
>>>What did I do wrong? I remember it working a couple of days ago, but I 
>>>changed a few settings here and there and now it's relying on the DLL to 
>>>function!
>>>Thanks in advance.
>>
>>
>>Xerces doesn't provide a makefile to build a static library for Visual 
>>C++ (it has one for Visual C++ 7.1 though). If you really need to have 
>>one, you should create a brand new library project, move all the files to 
>>the new project,  remove the .rc file and the Win32MsgLoader, add the 
>>InMemMsgLoader (also replacing the macro definition 
>>XML_USE_WIN32_MSGLOADER with the XML_USE_INMEM_MESSAGELOADER one)
>>
>>Alberto
>>
>I think you miss-understood me. Xerces _does_ provide means to easily 
>build static libraries in VC6.
>I already have a static library of Xerces built, but what was baffling was 
>how to link my program to that library without having my program rely on 
>the Xerces DLL.
>Any ideas?

Just do what I wrote: the library you see as the product of the compilation 
of the .dsp that ships with Xerces is just a "stub" library that redirects 
the calls to the DLL.

Alberto 



Re: Statically linking with Xerces.

Posted by Yotam Ofek <se...@zahav.net.il>.
Alberto Massari wrote:

> At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>
>> How can I statically link Xerces to my program (specifically, a DLL)?
>> I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces .lib 
>> file in the list of library files for my project, but still 
>> Depends.exe shows me that my DLL uses the xerces-c_2_6.dll.
>> What did I do wrong? I remember it working a couple of days ago, but 
>> I changed a few settings here and there and now it's relying on the 
>> DLL to function!
>> Thanks in advance.
>
>
> Xerces doesn't provide a makefile to build a static library for Visual 
> C++ (it has one for Visual C++ 7.1 though). If you really need to have 
> one, you should create a brand new library project, move all the files 
> to the new project,  remove the .rc file and the Win32MsgLoader, add 
> the InMemMsgLoader (also replacing the macro definition 
> XML_USE_WIN32_MSGLOADER with the XML_USE_INMEM_MESSAGELOADER one)
>
> Alberto
>
>
I think you miss-understood me. Xerces _does_ provide means to easily 
build static libraries in VC6.
I already have a static library of Xerces built, but what was baffling 
was how to link my program to that library without having my program 
rely on the Xerces DLL.
Any ideas?


Re: Statically linking with Xerces.

Posted by Alberto Massari <am...@datadirect.com>.
At 22.32 05/06/2005 +0200, Yotam Ofek wrote:
>How can I statically link Xerces to my program (specifically, a DLL)?
>I'm on Windows XP using MSVC++ 6 SP2. I've specified the Xerces .lib file 
>in the list of library files for my project, but still Depends.exe shows 
>me that my DLL uses the xerces-c_2_6.dll.
>What did I do wrong? I remember it working a couple of days ago, but I 
>changed a few settings here and there and now it's relying on the DLL to 
>function!
>Thanks in advance.

Xerces doesn't provide a makefile to build a static library for Visual C++ 
(it has one for Visual C++ 7.1 though). If you really need to have one, you 
should create a brand new library project, move all the files to the new 
project,  remove the .rc file and the Win32MsgLoader, add the 
InMemMsgLoader (also replacing the macro definition XML_USE_WIN32_MSGLOADER 
with the XML_USE_INMEM_MESSAGELOADER one)

Alberto