Re: [xml] Is LIBXML_STATIC_FOR_DLL safe to use in all circumstances?

Thanks for info.  Why one needs static for DLL is beyond me.  Why not use DLL for libxml2 if using DLL distribution – nobody will be updating your application and with a DLL they could update libxml2 … ouch.  I always use static with static – like I care that the application is a little bigger and more importantly they can use whatever libxml2 they want and I don’t care.  Plus in large Unix environments this is very efficient as AIX (my primary) only loads a program once.  Then it is in memory and everyone uses it.  If nobody is using it, it goes away and if it is not used often … who cares.  You also have the advantage of not smacking any libxml2 they might have.  I rarely have had a problem with libxml2 as dynamic (except Linux that can’t make a static to save itself) but I still have static.  Openssl and stunnel are much more likely to be trashed by the user.  And SSH use these so conflicting libraries can trash your connectivity.  At the very least, if you have to use DLLs then put them in your application directory with instructions to user that if they “want” to trash your library move to whatever directory … then you are still pretty safe.


As to your final question – I am not sure that it is safe.  Not so expert with Windows.  But generally I have found with libxml2 is that if they have a setting it is for a reason – and using it in other cases is not safe.  I would go on that assumption unless someone more expert on Windows tells you I am wrong (happens a lot J but I have used libxml2 on a ten O/S or so including Windows for decades since it was libxml – no two – and found it reliable and safe it you set it correctly).


Now if they would only simplify their Makefiles!!!!  All the clever grep/sed/awk etc. – yuck!  I use a script “mk” that determines the O/S and has a case statement to set flags for each O/S and then my Makefiles are clean (e.g. no conditional code, just different symbols for LDFLAGS, CXFLAGS, etc) as mk invokes make.


I use VS for Windows and have my own projects.  You can setup multiple builds with names and pre-process scripts to change flags – so worst case you have to do some setup and then it will be automated.  Get an IBM with AIX J  Much better!


I’d send you my projects except I bet my version of VS is too old for you and every version seems to need changes (yuck).  Windows has no clue about compatibility!  I have programs I wrote and lost the source to in 1988 – still working fine and being sold on current AIX.  UPS had a library for Host Access they last updated in 2004.  Still using it and they tried to shut off that service … and were stunned anyone was using a 15 year old library (on current machines).  That is how it should be!




From: xml [mailto:xml-bounces gnome org] On Behalf Of Dan Heinz
Sent: Thursday, August 22, 2019 7:19 AM
To: xml gnome org
Subject: [xml] Is LIBXML_STATIC_FOR_DLL safe to use in all circumstances?


I have a library that uses the static libxml2 library.  My library is distributed in three ways: a DLL, a static library that has the libxml2 library merged, and a static library that does not have libxml2 merged.

I have a Windows environment where my DLL is late-bound and being loaded and unloaded multiple times by an application using LoadLibrary and FreeLibrary.  After 1088 iterations of loading and unloading my DLL, the thread local storage allocation will fail (TLSAlloc) since it is not being freed by calling xmlCleanupParser. 


I see there is a define, LIBXML_STATIC_FOR_DLL, and a static build (libxml2_a_dll.lib) for this situation, and building and using this static library fixes the issue.


Is it safe to use the libxml2 build with the LIBXML_STATIC_FOR_DLL defined in all my library configurations (DLL and static with libxml2 merged)?  Is it safe to use when the DLL is early-bound?


Is this build safe to use for non-Windows platforms? 

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