SDL App with statically linked crt

Hello!

How do I build an SDL application, which is statically linked against
the crt? I am using MS VC9 and sdl version 1.2.14.

I tried the following:

  1. In my project settings I have set the option “Multi-threaded Debug
    (/MTd)”
  2. So I think it is necessary, to recompile SDL, so that the same
    version of the crt is used, right? So I recompiled SDL and SDLmain with
    "Multi-threaded (/MT)".
  3. Compiling were successful. So I copied the SDL.dll into my project
    dir and copied the .libs to the /lib directory
  4. Then I compiled my project without any linker errors. But a warning:
    “1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib’
    conflicts with use of other libs; use /NODEFAULTLIB:library”
  5. When I start my application, it crashes. The debugger shows me a line
    in “void SDL_FreeWAV(Uint8 *audio_buf)”.

What am I doing wrong?

Do I have to recompile SDL_Mixer as well? I didn’t change anything on
the mixer lib. It used to work as it is. Is is necessary to recompile
SDL_Mixer when I update the SDL verison?

Thank!
Christian

If you have changed your Code Generation settings you should make them the
same for all SDL related projects you are using in your app.

So if you are now using Multi-threaded Debug (/MTd)" for your app, you
should go into each SDL related project and set it the same way, then
rebuild.

SDL, SDL_mixer, SDL_image, etc.

That will also get rid of the linker warning in #4 below.> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Christian Meyer
Sent: Friday, June 04, 2010 1:28 PM
To: sdl at libsdl.org
Subject: [SDL] SDL App with statically linked crt

Hello!

How do I build an SDL application, which is statically linked against
the crt? I am using MS VC9 and sdl version 1.2.14.

I tried the following:

  1. In my project settings I have set the option “Multi-threaded Debug
    (/MTd)”
  2. So I think it is necessary, to recompile SDL, so that the same
    version of the crt is used, right? So I recompiled SDL and SDLmain with
    "Multi-threaded (/MT)".
  3. Compiling were successful. So I copied the SDL.dll into my project
    dir and copied the .libs to the /lib directory
  4. Then I compiled my project without any linker errors. But a warning:
    “1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib’
    conflicts with use of other libs; use /NODEFAULTLIB:library”
  5. When I start my application, it crashes. The debugger shows me a line
    in “void SDL_FreeWAV(Uint8 *audio_buf)”.

What am I doing wrong?

Do I have to recompile SDL_Mixer as well? I didn’t change anything on
the mixer lib. It used to work as it is. Is is necessary to recompile
SDL_Mixer when I update the SDL verison?

Thank!
Christian


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ken Rogoway schrieb:

If you have changed your Code Generation settings you should make them the
same for all SDL related projects you are using in your app.

So if you are now using Multi-threaded Debug (/MTd)" for your app, you
should go into each SDL related project and set it the same way, then
rebuild.

SDL, SDL_mixer, SDL_image, etc.

That will also get rid of the linker warning in #4 below.

Now I recompiled all SDL libs (SDL, SDL_net, SDL_Mixer). I get still the
same warning and the same crash.

Now I recompiled all SDL libs (SDL, SDL_net, SDL_Mixer). I get still the
same warning and the same crash.

Sorry, that was wrong. I am not able to compile SDL_Mixer. I get a lot
of linker errors, when I switch to “Multithreaded Debug”:

3>Linking…
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in
LIBCMTD.lib(dbgfree.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in
LIBCMTD.lib(dbgmalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in
LIBCMTD.lib(dbgcalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in
LIBCMTD.lib(getenv.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strchr already defined in
LIBCMTD.lib(strchr.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in
LIBCMTD.lib(atox.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fread already defined in
LIBCMTD.lib(fread.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno already defined in
LIBCMTD.lib(dosmap.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fopen already defined in
LIBCMTD.lib(fopen.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in
LIBCMTD.lib(fclose.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit already defined in
LIBCMTD.lib(crt0dat.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall
type_info::type_info(class type_info const &)”
(??0type_info@@AAE at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info &
__thiscall type_info::operator=(class type_info const &)”
(??4type_info@@AAEAAV0 at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3> Creating library .\Debug/SDL_mixer.lib and object .\Debug/SDL_mixer.exp
3>LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of
other libs; use /NODEFAULTLIB:library
3>.\Debug/SDL_mixer.dll : fatal error LNK1169: one or more multiply
defined symbols found

I wish I could help more. I just updated SDL to the latest from Mecurial,
then updated SDL_mixer to the latest in Mercurial

I get this error when compiling SDL_mixer:

effects_internal.c
c:\code\sdl_mixer\effects_internal.c(33) : fatal error C1083: Cannot open
include file: ‘SDL_getenv.h’: No such file or directory> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Christian Meyer
Sent: Friday, June 04, 2010 2:07 PM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL App with statically linked crt

Now I recompiled all SDL libs (SDL, SDL_net, SDL_Mixer). I get still the
same warning and the same crash.

Sorry, that was wrong. I am not able to compile SDL_Mixer. I get a lot
of linker errors, when I switch to “Multithreaded Debug”:

3>Linking…
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in
LIBCMTD.lib(dbgfree.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in
LIBCMTD.lib(dbgmalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in
LIBCMTD.lib(dbgcalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in
LIBCMTD.lib(getenv.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strchr already defined in
LIBCMTD.lib(strchr.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in
LIBCMTD.lib(atox.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fread already defined in
LIBCMTD.lib(fread.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno already defined in
LIBCMTD.lib(dosmap.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fopen already defined in
LIBCMTD.lib(fopen.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in
LIBCMTD.lib(fclose.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit already defined in
LIBCMTD.lib(crt0dat.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall
type_info::type_info(class type_info const &)”
(??0type_info@@AAE at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info &
__thiscall type_info::operator=(class type_info const &)”
(??4type_info@@AAEAAV0 at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3> Creating library .\Debug/SDL_mixer.lib and object .\Debug/SDL_mixer.exp
3>LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of
other libs; use /NODEFAULTLIB:library
3>.\Debug/SDL_mixer.dll : fatal error LNK1169: one or more multiply
defined symbols found


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Be aware of SDL licensing!On Fri, Jun 4, 2010 at 2:28 PM, Christian Meyer wrote:

Hello!

How do I build an SDL application, which is statically linked against the
crt? I am using MS VC9 and sdl version 1.2.14.

I tried the following:

  1. In my project settings I have set the option “Multi-threaded Debug
    (/MTd)”
  2. So I think it is necessary, to recompile SDL, so that the same version of
    the crt is used, right? So I recompiled SDL and SDLmain with “Multi-threaded
    (/MT)”.
  3. Compiling were successful. So I copied the SDL.dll into my project dir
    and copied the .libs to the /lib directory
  4. Then I compiled my project without any linker errors. But a warning:
    “1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib’
    conflicts with use of other libs; use /NODEFAULTLIB:library”
  5. When I start my application, it crashes. The debugger shows me a line in
    "void SDL_FreeWAV(Uint8 *audio_buf)".

What am I doing wrong?

Do I have to recompile SDL_Mixer as well? I didn’t change anything on the
mixer lib. It used to work as it is. Is is necessary to recompile SDL_Mixer
when I update the SDL verison?

Thank!
Christian


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

Donny Viszneki schrieb:

Be aware of SDL licensing!

I don’t want to link SDL statically, I want to link the crt statically,
to avoid the dependence on the msvcrt dlls.

Christian Meyer schrieb:

I am not able to compile SDL_Mixer. I get a lot
of linker errors, when I switch to “Multithreaded Debug”:

3>Linking…
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in
LIBCMTD.lib(dbgfree.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in
LIBCMTD.lib(dbgmalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in
LIBCMTD.lib(dbgcalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in
LIBCMTD.lib(getenv.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strchr already defined in
LIBCMTD.lib(strchr.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in
LIBCMTD.lib(atox.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fread already defined in
LIBCMTD.lib(fread.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno already defined in
LIBCMTD.lib(dosmap.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fopen already defined in
LIBCMTD.lib(fopen.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in
LIBCMTD.lib(fclose.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit already defined in
LIBCMTD.lib(crt0dat.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall
type_info::type_info(class type_info const &)”
(??0type_info@@AAE at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info &
__thiscall type_info::operator=(class type_info const &)”
(??4type_info@@AAEAAV0 at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3> Creating library .\Debug/SDL_mixer.lib and object
.\Debug/SDL_mixer.exp
3>LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of
other libs; use /NODEFAULTLIB:library
3>.\Debug/SDL_mixer.dll : fatal error LNK1169: one or more multiply
defined symbols found

I still was not able to compile SDL_Mixer with the option “Multithreaded
Debug” for the crt. How is SDL_Mixer compiled with static crt?

Thanks,
Christian

The key to getting this to compile is making sure that everything you build
has the same setting in the Code Generation section of the Project
Configuration.

So if you are using /MTd (Multi-threaded Debug) then make sure you do the
same thing for SDL, and any other projects you are building and linking
(SDL_image, SDL_ttf, etc). This also includes your own code for your
game/app.

Ken Rogoway> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Christian Meyer
Sent: Sunday, June 06, 2010 3:52 AM
To: sdl at libsdl.org
Subject: [SDL] Compiling SDL_Mixer 1.2.11 with static crt

Christian Meyer schrieb:

I am not able to compile SDL_Mixer. I get a lot
of linker errors, when I switch to “Multithreaded Debug”:

3>Linking…
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in
LIBCMTD.lib(dbgfree.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in
LIBCMTD.lib(dbgmalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in
LIBCMTD.lib(dbgcalloc.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in
LIBCMTD.lib(getenv.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strchr already defined in
LIBCMTD.lib(strchr.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in
LIBCMTD.lib(atox.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fread already defined in
LIBCMTD.lib(fread.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno already defined in
LIBCMTD.lib(dosmap.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fopen already defined in
LIBCMTD.lib(fopen.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in
LIBCMTD.lib(fclose.obj)
3>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit already defined in
LIBCMTD.lib(crt0dat.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall
type_info::type_info(class type_info const &)”
(??0type_info@@AAE at ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
3>MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info &
__thiscall type_info::operator=(class type_info const &)”
(??4type_info@@AAEAAV0 at ABV0@@Z) already defined in
LIBCMTD.lib(typinfo.obj)
3> Creating library .\Debug/SDL_mixer.lib and object
.\Debug/SDL_mixer.exp
3>LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of
other libs; use /NODEFAULTLIB:library
3>.\Debug/SDL_mixer.dll : fatal error LNK1169: one or more multiply
defined symbols found

I still was not able to compile SDL_Mixer with the option “Multithreaded
Debug” for the crt. How is SDL_Mixer compiled with static crt?

Thanks,
Christian


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ken Rogoway schrieb:

The key to getting this to compile is making sure that everything you build
has the same setting in the Code Generation section of the Project
Configuration.

So if you are using /MTd (Multi-threaded Debug) then make sure you do the
same thing for SDL, and any other projects you are building and linking
(SDL_image, SDL_ttf, etc). This also includes your own code for your
game/app.

Ken Rogoway

I already recompiled all other modules, except SDL mixer. So my current
problem is to compile SDL Mixer. Independent from my own app and the
other SDL libraries.

So my question is, how can I compile SDL_Mixer with the /MTd
(Multi-threaded Debug) setting, because I get a lot of linker errors.

Christian

Now I finally got all libs compiled with the “/MTd (Multi-threaded
Debug)” Option. And now my app compiles without any linker warning.

But the crash still occurs, when the app is loading the first .ogg file.
It crashes when freeing some memory in the sdl lib, which was former
allocated by the sdl mixer lib.

Is there any way to get this running?

Thanks,
Christian