You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Milan Tomic <mi...@setcce.org> on 2003/12/11 13:12:35 UTC

Static Linking

	How can I statically link Xerces in my app? I'm using VC++ 6.
I've tried to remove xerces.lib file from Object/library modules list
(Project | Settings... | Linktab) of my project and to add path to
Xerces *.obj files in Tools | Options... | Directories tab. But still I
got a lot of "unresolved external symbol" linker errors.

Thank you.

RE: Static Linking

Posted by MA...@dstsystems.com.



The static lib was large( about 7 MB for the release version ). In my case,
the resulting executable( it was actually a DLL ) was about 2 MB, but I
wasn't particularly careful about what Xerces functionality I used.  All I
can say is try it and see what happens.

Marc Robertson
Staff Consultant
AWD Development
DST Systems, Inc.


                                                                           
             "Milan Tomic"                                                 
             <milan@setcce.org                                             
             >                                                          To 
                                       <xe...@xml.apache.org>       
             12/12/2003 08:27                                           cc 
             AM                                                            
                                                                   Subject 
                                       RE: Static Linking                  
             Please respond to                                             
             xerces-c-dev@xml.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           





    Thank you very much for sharing it with us. I am developing app that
people would download through Internet. It includes Xerces and Xalan
dlls (about 2 MB compressed). My goal is to make app that would have
less then 1 MB in total size (Xerces and Xalan included). So, I'd like
not to use Xerces.dll, but to link its source code into my project. That
way compiler will not include all Xerces *.obj files into my executable
(or dll), but only those I need (use). I have tried to remove Xerces.lib
file from my project and to add paths to Xerces *.obj files in Tools |
Options... | Directories tab, but I didn't had much success. Compiler
couldn't find definitions of Xerces function. Perhaps I need something
similar:

> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj

    As much as I could understand you have produced XercesD.lib file for
staticaly linking into your executable file (or dll). How big is it?


> -----Original Message-----
> From: MARobertson@dstsystems.com [mailto:MARobertson@dstsystems.com]
> Sent: Friday, December 12, 2003 3:09 PM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: Static Linking
>
>
>
>
>
>
> I was able to link Xerces-c staticly, with VC++ 6.0  Although
> it was a bit of a hack. First, I changed the VCPPDefs.hpp
> file to make the PLATFORM_EXPORT and PLATFORM_IMPORT macros
> empty if XERCES_STATIC_LIB is
> defined:
>
> #ifdef XERCES_STATIC_LIB
> #define PLATFORM_EXPORT
> #define PLATFORM_IMPORT
> #else
> #define PLATFORM_EXPORT     __declspec(dllexport)
> #define PLATFORM_IMPORT     __declspec(dllimport)
> #endif
>
> Then, I added a custom build step to the end of the build,
> that executes the lib utility:
>
> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj
>
> Finally, I defined the XERCES_STATIC_LIB macro in the Project
> Settings.
>
> This does still build the dll( couldn't figure out how to
> convert the project to just do the static lib ), and it is
> unusable, since nothing is exported.  However, since I just
> throw that away, I didn't care.
>
> I've tested this with the application I wrote using Xerces,
> and it worked fine for that. Now, there are a large number of
> the Xerces-c API's that I don't use( none of the Namespace
> specific ones, for example ), so I can't say if this will
> work for everyone.  However, I would expect that, if I can
> get to one function, I should be able to get to them all.
>
> Hope this helps.
>
>
> Marc Robertson
> Staff Consultant
> AWD Development
> DST Systems, Inc.
>
>
>
>
>              "Denny Vrandecic"
>
>              <de...@nodix.de>
>
>
>           To
>              12/11/2003 06:16
> <xe...@xml.apache.org>
>              AM
>           cc
>
>
>
>      Subject
>              Please respond to         Re: Static Linking
>
>              xerces-c-dev@xml.
>
>                 apache.org
>
>
>
>
>
>
>
>
>
>
>
>
>
> Xerce-C is not supposed to work statically. I think it is on
> the ToDo-List to create a static version, but there's no
> promise when this will be avaiable.
>
> Best regards,
> Denny
>
>
>  ----- Original Message -----
>  From: Milan Tomic
>  To: Xerces-C
>  Sent: Thursday, December 11, 2003 1:12 PM
>  Subject: Static Linking
>
>
>
>
>          How can I statically link Xerces in my app? I'm
> using VC++ 6. I've  tried to remove xerces.lib file from
> Object/library modules list (Project  | Settings... |
> Linktab) of my project and to add path to Xerces *.obj  files
> in Tools | Options... | Directories tab. But still I got a
> lot of  "unresolved external symbol" linker errors.
>
>
>  Thank you.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Unexpected errors in SAX2 parser Xerces C++ v2.3.0

Posted by Alberto Massari <am...@progress.com>.
At 16.27 19/12/2003 -0600, Curtis Leach wrote:
>Interesting,
>
>So to fix my entry, I'd do the following:
><cust_name>CABLE &amp; WIRELESS</cust_name>
>
>But this breaks it into 2 calls to characters()
>   startElement (cust_name)
>   characters (CABLE , 6)
>   characters (& WIRELESS, 10)
>   endElement (cust_name)
>
>Is there any way to fix it so it only makes 1 call to characters()?

No; the characters() call is allowed by the SAX specs to be called multiple 
times. This could also occur if you had a text node 100Kb big, as the 
parser works on internal buffers of less than 50Kb...

>Also what is the escape sequence for "<" & ">" ?

&gt; and &lt;
When inside attribute values, also " and ' need to be escaped, using &quot; 
and &apos;

Alberto





>Curtis
>
>-----Original Message-----
>From: Alberto Massari [mailto:amassari@progress.com]
>Sent: Friday, December 19, 2003 4:10 PM
>To: xerces-c-dev@xml.apache.org
>Subject: Re: Unexpected errors in SAX2 parser Xerces C++ v2.3.0
>
>
>At 15.53 19/12/2003 -0600, Curtis Leach wrote:
> >In parsing some XML documents, I'm getting the following SAXParseException
> >error when parsing my XML document.
> >
> >"Expected entity name for reference"
> >
> >After some research I tracked it down to the following tags.
> >     <cust_name>CABLE & WIRELESS</cust_name>
> >
> >My trace showed:
> >    startElement (cust_name)
> >    characters (CABLE , 6)
> >The exception is thrown by Xercesc before control is returned on the next
> >call.
> >
> >My question is: is the "&" a special char in XML ?  If so, where can I find
> >a list of special chars in XML? And how do I escape them so that they are
> >allowed in an XML document.
>
>Yes, "&" is a special character (as well as "<" and ">"); it needs to be
>escaped using the string "&amp;"
>
>Alberto
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Unexpected errors in SAX2 parser Xerces C++ v2.3.0

Posted by Michael Glavassevich <mr...@apache.org>.
On Fri, 19 Dec 2003, Curtis Leach wrote:

> what is the escape sequence for "<" & ">" ?

&lt; and &gt;

---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Unexpected errors in SAX2 parser Xerces C++ v2.3.0

Posted by Michael Glavassevich <mr...@apache.org>.
Hi Curtis,

SAX allows parsers to split contiguous text into as many characters
callbacks as they choose on whatever boundaries they choose. The
motivation was to give parsers this freedom for efficiency, so in general
your code needs to be able handle multiple callbacks by accumulating text
until the next non-characters callback.

On Fri, 19 Dec 2003, Curtis Leach wrote:

> Interesting,
>
> So to fix my entry, I'd do the following:
> <cust_name>CABLE &amp; WIRELESS</cust_name>
>
> But this breaks it into 2 calls to characters()
>   startElement (cust_name)
>   characters (CABLE , 6)
>   characters (& WIRELESS, 10)
>   endElement (cust_name)
>
> Is there any way to fix it so it only makes 1 call to characters()?  Also
> what is the escape sequence for "<" & ">" ?
>
> Curtis
>
> -----Original Message-----
> From: Alberto Massari [mailto:amassari@progress.com]
> Sent: Friday, December 19, 2003 4:10 PM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: Unexpected errors in SAX2 parser Xerces C++ v2.3.0
>
>
> At 15.53 19/12/2003 -0600, Curtis Leach wrote:
> >In parsing some XML documents, I'm getting the following SAXParseException
> >error when parsing my XML document.
> >
> >"Expected entity name for reference"
> >
> >After some research I tracked it down to the following tags.
> >     <cust_name>CABLE & WIRELESS</cust_name>
> >
> >My trace showed:
> >    startElement (cust_name)
> >    characters (CABLE , 6)
> >The exception is thrown by Xercesc before control is returned on the next
> >call.
> >
> >My question is: is the "&" a special char in XML ?  If so, where can I find
> >a list of special chars in XML? And how do I escape them so that they are
> >allowed in an XML document.
>
> Yes, "&" is a special character (as well as "<" and ">"); it needs to be
> escaped using the string "&amp;"
>
> Alberto
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>

-- 
---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Unexpected errors in SAX2 parser Xerces C++ v2.3.0

Posted by Curtis Leach <cu...@mci.com>.
Interesting,

So to fix my entry, I'd do the following:
<cust_name>CABLE &amp; WIRELESS</cust_name>

But this breaks it into 2 calls to characters()
  startElement (cust_name)
  characters (CABLE , 6)
  characters (& WIRELESS, 10)
  endElement (cust_name)

Is there any way to fix it so it only makes 1 call to characters()?  Also
what is the escape sequence for "<" & ">" ?

Curtis

-----Original Message-----
From: Alberto Massari [mailto:amassari@progress.com]
Sent: Friday, December 19, 2003 4:10 PM
To: xerces-c-dev@xml.apache.org
Subject: Re: Unexpected errors in SAX2 parser Xerces C++ v2.3.0


At 15.53 19/12/2003 -0600, Curtis Leach wrote:
>In parsing some XML documents, I'm getting the following SAXParseException
>error when parsing my XML document.
>
>"Expected entity name for reference"
>
>After some research I tracked it down to the following tags.
>     <cust_name>CABLE & WIRELESS</cust_name>
>
>My trace showed:
>    startElement (cust_name)
>    characters (CABLE , 6)
>The exception is thrown by Xercesc before control is returned on the next
>call.
>
>My question is: is the "&" a special char in XML ?  If so, where can I find
>a list of special chars in XML? And how do I escape them so that they are
>allowed in an XML document.

Yes, "&" is a special character (as well as "<" and ">"); it needs to be
escaped using the string "&amp;"

Alberto



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Unexpected errors in SAX2 parser Xerces C++ v2.3.0

Posted by Alberto Massari <am...@progress.com>.
At 15.53 19/12/2003 -0600, Curtis Leach wrote:
>In parsing some XML documents, I'm getting the following SAXParseException
>error when parsing my XML document.
>
>"Expected entity name for reference"
>
>After some research I tracked it down to the following tags.
>     <cust_name>CABLE & WIRELESS</cust_name>
>
>My trace showed:
>    startElement (cust_name)
>    characters (CABLE , 6)
>The exception is thrown by Xercesc before control is returned on the next
>call.
>
>My question is: is the "&" a special char in XML ?  If so, where can I find
>a list of special chars in XML? And how do I escape them so that they are
>allowed in an XML document.

Yes, "&" is a special character (as well as "<" and ">"); it needs to be 
escaped using the string "&amp;"

Alberto 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Static Linking

Posted by MA...@dstsystems.com.



Bring up the Project Settings, then click on the Custom Build tab.  The
Settings dialog has more tabs than will display at once.  You will need to
use the arrow buttons to the right of the tabs to scroll through the rest
of the tabs.  Once that tab is selected, enter the commands into the
"Commands" edit box.  One thing I forgot to mention is that you also need
to enter:

$(OutDir)\xercesD.lib

into the "Outputs" edit box.  VCPP uses that to determine dependencies.


Marc Robertson
Staff Consultant
AWD Development
DST Systems, Inc.


                                                                           
             "Milan Tomic"                                                 
             <milan@setcce.org                                             
             >                                                          To 
                                       <xe...@xml.apache.org>       
             12/12/2003 09:01                                           cc 
             AM                                                            
                                                                   Subject 
                                       RE: Static Linking                  
             Please respond to                                             
             xerces-c-dev@xml.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           





> Then, I added a custom build step to the end of the build,
> that executes the lib utility:
> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj
Where do I have to put this? I can't find location (lib utility). In
Project | Setting... somewhere or in some file?

Thank you.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Static Linking

Posted by Milan Tomic <mi...@setcce.org>.
> Then, I added a custom build step to the end of the build,
> that executes the lib utility:
> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj
Where do I have to put this? I can't find location (lib utility). In
Project | Setting... somewhere or in some file?

Thank you.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Static Linking

Posted by Milan Tomic <mi...@setcce.org>.
    Thank you very much for sharing it with us. I am developing app that
people would download through Internet. It includes Xerces and Xalan
dlls (about 2 MB compressed). My goal is to make app that would have
less then 1 MB in total size (Xerces and Xalan included). So, I'd like
not to use Xerces.dll, but to link its source code into my project. That
way compiler will not include all Xerces *.obj files into my executable
(or dll), but only those I need (use). I have tried to remove Xerces.lib
file from my project and to add paths to Xerces *.obj files in Tools |
Options... | Directories tab, but I didn't had much success. Compiler
couldn't find definitions of Xerces function. Perhaps I need something
similar:

> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj

    As much as I could understand you have produced XercesD.lib file for
staticaly linking into your executable file (or dll). How big is it?


> -----Original Message-----
> From: MARobertson@dstsystems.com [mailto:MARobertson@dstsystems.com] 
> Sent: Friday, December 12, 2003 3:09 PM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: Static Linking
> 
> 
> 
> 
> 
> 
> I was able to link Xerces-c staticly, with VC++ 6.0  Although 
> it was a bit of a hack. First, I changed the VCPPDefs.hpp 
> file to make the PLATFORM_EXPORT and PLATFORM_IMPORT macros 
> empty if XERCES_STATIC_LIB is
> defined:
> 
> #ifdef XERCES_STATIC_LIB
> #define PLATFORM_EXPORT
> #define PLATFORM_IMPORT
> #else
> #define PLATFORM_EXPORT     __declspec(dllexport)
> #define PLATFORM_IMPORT     __declspec(dllimport)
> #endif
> 
> Then, I added a custom build step to the end of the build, 
> that executes the lib utility:
> 
> cd $(IntDir)
> lib /out:$(OutDir)\xercesD.lib *.obj
> 
> Finally, I defined the XERCES_STATIC_LIB macro in the Project 
> Settings.
> 
> This does still build the dll( couldn't figure out how to 
> convert the project to just do the static lib ), and it is 
> unusable, since nothing is exported.  However, since I just 
> throw that away, I didn't care.
> 
> I've tested this with the application I wrote using Xerces, 
> and it worked fine for that. Now, there are a large number of 
> the Xerces-c API's that I don't use( none of the Namespace 
> specific ones, for example ), so I can't say if this will 
> work for everyone.  However, I would expect that, if I can 
> get to one function, I should be able to get to them all.
> 
> Hope this helps.
> 
> 
> Marc Robertson
> Staff Consultant
> AWD Development
> DST Systems, Inc.
> 
> 
>                                                               
>              
>              "Denny Vrandecic"                                
>              
>              <de...@nodix.de>                                 
>              
>                                                               
>           To 
>              12/11/2003 06:16          
> <xe...@xml.apache.org>       
>              AM                                               
>           cc 
>                                                               
>              
>                                                               
>      Subject 
>              Please respond to         Re: Static Linking     
>              
>              xerces-c-dev@xml.                                
>              
>                 apache.org                                    
>              
>                                                               
>              
>                                                               
>              
>                                                               
>              
>                                                               
>              
> 
> 
> 
> 
> Xerce-C is not supposed to work statically. I think it is on 
> the ToDo-List to create a static version, but there's no 
> promise when this will be avaiable.
> 
> Best regards,
> Denny
> 
> 
>  ----- Original Message -----
>  From: Milan Tomic
>  To: Xerces-C
>  Sent: Thursday, December 11, 2003 1:12 PM
>  Subject: Static Linking
> 
> 
> 
> 
>          How can I statically link Xerces in my app? I'm 
> using VC++ 6. I've  tried to remove xerces.lib file from 
> Object/library modules list (Project  | Settings... | 
> Linktab) of my project and to add path to Xerces *.obj  files 
> in Tools | Options... | Directories tab. But still I got a 
> lot of  "unresolved external symbol" linker errors.
> 
> 
>  Thank you.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Static Linking

Posted by MA...@dstsystems.com.



I was able to link Xerces-c staticly, with VC++ 6.0  Although it was a bit
of a hack. First, I changed the VCPPDefs.hpp file to make the
PLATFORM_EXPORT and PLATFORM_IMPORT macros empty if XERCES_STATIC_LIB is
defined:

#ifdef XERCES_STATIC_LIB
#define PLATFORM_EXPORT
#define PLATFORM_IMPORT
#else
#define PLATFORM_EXPORT     __declspec(dllexport)
#define PLATFORM_IMPORT     __declspec(dllimport)
#endif

Then, I added a custom build step to the end of the build, that executes
the lib utility:

cd $(IntDir)
lib /out:$(OutDir)\xercesD.lib *.obj

Finally, I defined the XERCES_STATIC_LIB macro in the Project Settings.

This does still build the dll( couldn't figure out how to convert the
project to just do the static lib ), and it is unusable, since nothing is
exported.  However, since I just throw that away, I didn't care.

I've tested this with the application I wrote using Xerces, and it worked
fine for that. Now, there are a large number of the Xerces-c API's that I
don't use( none of the Namespace specific ones, for example ), so I can't
say if this will work for everyone.  However, I would expect that, if I can
get to one function, I should be able to get to them all.

Hope this helps.


Marc Robertson
Staff Consultant
AWD Development
DST Systems, Inc.


                                                                           
             "Denny Vrandecic"                                             
             <de...@nodix.de>                                              
                                                                        To 
             12/11/2003 06:16          <xe...@xml.apache.org>       
             AM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         Re: Static Linking                  
             xerces-c-dev@xml.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           
                                                                           




Xerce-C is not supposed to work statically. I think it is on the ToDo-List
to create a static version, but there's no promise when this will be
avaiable.

Best regards,
Denny


 ----- Original Message -----
 From: Milan Tomic
 To: Xerces-C
 Sent: Thursday, December 11, 2003 1:12 PM
 Subject: Static Linking




         How can I statically link Xerces in my app? I'm using VC++ 6. I've
 tried to remove xerces.lib file from Object/library modules list (Project
 | Settings... | Linktab) of my project and to add path to Xerces *.obj
 files in Tools | Options... | Directories tab. But still I got a lot of
 "unresolved external symbol" linker errors.


 Thank you.




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Static Linking

Posted by Denny Vrandecic <de...@nodix.de>.
Static LinkingXerce-C is not supposed to work statically. I think it is on the ToDo-List to create a static version, but there's no promise when this will be avaiable.

Best regards,
Denny


  ----- Original Message ----- 
  From: Milan Tomic 
  To: Xerces-C 
  Sent: Thursday, December 11, 2003 1:12 PM
  Subject: Static Linking




          How can I statically link Xerces in my app? I'm using VC++ 6. I've tried to remove xerces.lib file from Object/library modules list (Project | Settings... | Linktab) of my project and to add path to Xerces *.obj files in Tools | Options... | Directories tab. But still I got a lot of "unresolved external symbol" linker errors.

  Thank you.