STL and DLLs

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
ZacMW
Gnoblar
Posts: 1
Joined: Fri Jun 14, 2013 11:32 pm

STL and DLLs

Post by ZacMW »

So, I know there are a horrendous number of articles on this subject, but the more I dive into the subject the more I found there are several different ways to do the whole thing.

So, eventually after reading several articles that talk about the subject, I came to the conclusion that if a DLL is built with each individual compiler and then when someone wants to use the DLL they will have to use one of the supported compilers and the STL will work correctly.

If I'm wrong on this subject, is there any "correct" way to use the STL with dlls? In my opinion the STL is very viable resource that I'd rather not have to abandon.
Especially since there is no way I want to spend the time writing my own implementations of vector, string, map, shared_ptr and etc.

The reason I came here to ask is, because I'm pretty sure OGRE uses the STL and it works fine across most platforms, so I'm sure you guys have come up with a concrete solution.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Re: STL and DLLs

Post by Oogst »

As far as I know, you just need the .LIB and the .DLL that come with SDL and then it is fine, no matter what compiler you use.

Also, just put the SDL DLL in the same folder as your own executable and provide it to whoever downloads your application. That way it doesn't matter, since your users don't compile SDL themselves, they just run your application and get whatever your provided them.
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
Transporter
Minaton
Posts: 933
Joined: Mon Mar 05, 2012 11:37 am
Location: Germany
x 110

Re: STL and DLLs

Post by Transporter »

@Oogst
The question was about STL and not SDL :wink:

@ZacMW
The STL DLLs are included in the redistributable package of the selected compiler. If you like you can also use the static version of STL, so you don't have to distribute the required redistributable package.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Re: STL and DLLs

Post by Oogst »

Doh, overread that!

In my experience no DLL needs to be included for STL at all. If you work in Visual Studio, you always need the vcredist thing, regardless of whether you use STL or not, and nothing else is needed.

Also, most (all?) of STL is in templates, so it will go directly into your own executable anyway.
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: STL and DLLs

Post by Klaim »

No actually it's because you use the standard library that the redistribuable are necessary IF the user don't have these dlls already on his Windows, which happen if you use a compiler version more advanced than the version released in the same time than the Windows version.
The "*crt" means "c/c++ runtime". There are ways to not require these dlls, one is to link them as static library like transporter said, another is to not use the standard library at all (and I think you also need to remove some libs from the project settings).
Post Reply