Web lists-archives.com

Re: [Mingw-users] Multiple definition of `vsnprintf' when building C++ programs

> From: Keith Marshall <keithmarshall@xxxxxxxxxxxxxxxxxxxxx>
> Date: Tue, 9 May 2017 22:59:12 +0100
> > (I assume that undefining __USE_MINGW_ANSI_STDIO before including
> > stdio.h is not a good idea, since it will cause a non-compliant
> > vsnprintf from msvcrt to be used, which will subtly break the
> > program.)
> Possibly not.  Legacy MSVCRT.DLL exported Microsoft's (incompatible) 
> _vsnprintf(), IIRC; it didn't export vsnprintf(), which should always 
> be resolved to the entry in libmingwex.a, (or libmingwex.dll.a).

Thanks, this means I at least have a workaround for mingwrt-5.0.

>   $ mingw32-g++ -std=gnu++11 -O2 ts.cpp -o ts.exe
>   <success -- no diagnostic output>
> i.e. without doing anything, it appears that I am not reproducing the 
> link failure you are reporting.  So, what is the difference between my 
> link and yours?  Dynamic vs. static linking of libmingwex, perhaps?

Yes, I link libmingwex statically.

It is of course expected that linking against a DLL will not hit this
problem.  I'd like to avoid a dynamic link against libmingwex, because
otherwise distributing a GDB binary would need to distribute the
libmingwex DLL, which increases the probability of a DLL hell on the
end-user's machines, and also will require me to provide the sources
for libmingwex near the binaries.

So I hope you will find a solution that works for static linking as


Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe