[vorbis] Trying to figure out the library...

John Wedoff john at wedoff.org
Mon Apr 8 10:01:15 PDT 2002



I mostly lurk here, but I think I can expand on this a little bit
Here are some links to MSDN articles discussing this issue:
http://msdn.microsoft.com/library/en-us/vccore/html/LNK4098.asp
http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.MD.2c_2f.ML.2c
_2f.MT.2c_2f.LD.asp

<p>Basically when you build a library with VC++, you link it against one of six
C runtime libraries:

    C Runtime Library           Switch    Library    Macro(s) Defined
    ----------------------------------------------------------------
    Single Threaded             /ML       LIBC       (none)
    Static MultiThread          /MT       LIBCMT     _MT
    Dynamic Link (DLL)          /MD       MSVCRT     _MT and _DLL
    Debug Single Threaded       /MLd      LIBCD      _DEBUG
    Debug Static MultiThread    /MTd      LIBCMTD    _DEBUG and _MT
    Debug Dynamic Link (DLL)    /MDd      MSVCRTD    _DEBUG, _MT, and _DLL

The library and the code using the library need to use the same C runtime
library, or bad nasty things will happen. (Random segfaults and the like).
Microsoft suggests putting something like the following in headers to test
to make certain that the libraries are linked against code using the same C
runtime:

    // MyReusableDynamicLinkReleaseLibrary.h
    #if !defined(_MT) || !defined(_DLL) || defined(_DEBUG)
        #error The /MD compiler switch is required.
    #endif

It's pretty ugly, and I'm not suggesting it should be added. (And since I
*haven't* ever looked at the source for vorbis myself, it might already be
there for all I know...)

Hope this helps.

-John

----- Original Message -----
From: "Shon Ferguson" <shonferg at adelphia.net>
To: <vorbis at xiph.org>
Sent: Monday, April 08, 2002 9:26 AM
Subject: RE: [vorbis] Trying to figure out the library...

<p>> >>Actually, I'd love to put this in the FAQ.  Can someone explain very
> clearly
> what the problem was and what the solution was to a non-Windows
> programmer?  Thanks.
>
> I'm still trying to figure out exactly why I had to make my app use the
> multi-threaded safe version of the Windows library to use the OGG libs.  I
> use all sorts of libs with DirectX and can still optionally choose one or
> the other.  Unless Ogg is multi-threaded (Can you do that and be cross
> platform?) The closest thing I can find to a possible answer is the
> context-help text that I get when I click on the library selection box in
> MSVC++ which reads:
>
> "This option determines whether the program being built has single or
> multi-threaded support.  This setting changes the value of the /MD, /ML,
and
> /MT compiler switches.  It is usually best to use the mutli-threaded
options
> when building a DLL.  If you specify a single-threaded option, your DLL
will
> work reliably only when called by single-thread applications."
>
> But I'm sure the people who helped me know why the mutli-threaded DLL
> version of the libraries is required.  Perhaps it has something to do with
> the way it was compiled originally as I am using this pre-compiled
version.
>
> At any rate, the solution, in MSVC++ 6.0, is to go to 'Project ->
> Settings... [Alt+F7]', click the 'C/C++' tab in the resulting dialog,
choose
> 'Code Generation' from the 'Category' drop down on that tab page, and
choose
> 'Multithreaded DLL' from the 'Use runtime library.'
>
> That will cause MSVC++ to link in the Multithreaded DLL versions of the
> Windows library files rather than the ones optimized for single threaded
> apps, or debugging, or even the standard Multithreaded libraries (which
seem
> to cause link errors).
>
> Also you may want to note that to use the lib files you either have to
> include them in the project directly or list them in 'Project ->
> Settings...', 'Link' tab, 'Project Options' text box.  I believe there is
a
> pre-compiler directive to do this as well but I can't recall it.
>
> Hope that helps :)
>
> --Shon
>
>
>
> -----Original Message-----
> From: owner-vorbis at xiph.org [mailto:owner-vorbis at xiph.org]On Behalf Of
> volsung at asu.edu
> Sent: Monday, April 08, 2002 1:59 AM
> To: vorbis at xiph.org
> Subject: RE: [vorbis] Trying to figure out the library...
>
>
> On Sun, 7 Apr 2002, Shon Ferguson wrote:
>
> > >>Make sure you're using Multithreaded DLL of the RT libs.
> >
> > Aah hah!  I love you! ::chortles::
> >
> > That really should be in a FAQ somewhere... or maybe I just missed it.
At
> > any rate, thanks!
>
> Actually, I'd love to put this in the FAQ.  Can someone explain very
clearly
> what the problem was and what the solution was to a non-Windows
> programmer?  Thanks.
>
> ---
> Stan Seibert
>
>
>
> --- >8 ----
> List archives:  http://www.xiph.org/archives/
> Ogg project homepage: http://www.xiph.org/ogg/
> To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
> containing only the word 'unsubscribe' in the body.  No subject is needed.
> Unsubscribe messages sent to the list will be ignored/filtered.
>
>
> --- >8 ----
> List archives:  http://www.xiph.org/archives/
> Ogg project homepage: http://www.xiph.org/ogg/
> To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
> containing only the word 'unsubscribe' in the body.  No subject is needed.
> Unsubscribe messages sent to the list will be ignored/filtered.
>

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list