Re: [xml] wrong compiler settings for MSVC in makefile



Well...if the runtimes are different the application won't even link 
for me, because symbols are duplicated.
The "Multithreaded" setting for runtime wasn't the default one. It's 
normally the "Singlethreaded". It was changed for that apllication to 
ensure it work's multithreaded. In the case of a non-static lib the 
"/MD" for libxml2 is okay, but as soon as I would link it into an 
application, I would run into the problem. I just compiled the static 
with "/MT" and it works fine, so it's no big problem for me.
I am not sure, why MS has to use different runtimes instead of just 
using defines, which would ease the whole thing, maybe rise other 
problems...as long as I get it to work I can live with it.

Things are intentionally set the way they are. It is imperative that all
libraries, have they debug symbols or not, be they static or dynamic, use
the same runtime.

When runtimes are different then:
- you do a xmlOutputBufferCreateFile(...); and your app will crash.
- you do a xmlOutputBufferCreateFd(...); and your app will crash.
- you do a xmlFreeDoc(xmlNewDoc(...)); and your app will crash.

Standard descriptors like stdin or stdout one might use in above functions
are not compatible between available runtimes. Similarily, the FILE*
returned from fopen isn't the same in all available runtimes. These pointers
and file descriptors can be used only by functions in their respective
runtimes.

Functions like xmlFree are macros which expand to free from the runtime.
But, they expand to free from your runtime, not libxml's runtime. As it
appears, malloc from one runtime is not compatible to free from another.

Another issue is compatibility between binaries produced by different
compilers, msvc and mingw for example.

To avoid all kinds of problems, I had to settle for one runtime and use it
exclusively everywhere. This implies that all applications which are based
on the binaries I produce must use the same runtime. I decided to use
msvcrt.dll and I never regretted it. Now, there are too many apps out there
to break by changing it.

First ask yourself if you really need a different runtime.
99.999999999999999% requests for another runtime come from people who want
it just because it's the default setting in Visual Studio IDE, and so they
believe it must be the right way. If your reason is different to that, then
we can add an apropriate option to configure.js and makefile.msvc to ease
the build with a different runtime.

Ciao,
Igor






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