Jump to content
  • Advertisement
Sign in to follow this  
TalissonBento

Should i to compile using static library or shared library?

This topic is 1439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

  Hello everyone, i've been reading some articles about how to compile projects and with it came the question on my mind about shared library and static.

  What's better way to compile my game?
  What become it fastest?
  Advantage and disadvantage to use it?

 Sorry about my english, but this forum is the better know and is helping me so much. smile.pngtongue.png

 Please this question must be answered for Linux, Windows and Mac.

Share this post


Link to post
Share on other sites
Advertisement

I recently came upon this problem in Windows where there were two shared libraries compiling with Lua statically, which caused a crash when passing a lua_State* between the two. It was fixed by linking Lua as a shared library, which is a wonderfully descriptive name for when it is appropriate to use, seeing as it was shared by the two libraries.

 

It will differ per project, and most libraries will say when they are better done as static libraries. If you want some definitive answer, then link everything shared until the library explicitly says to do it static.

 

In the case of choosing static or shared, the difference in code execution speed will not be great enough to make a difference. There are some link-time optimizations that can happen with static libraries, but I wouldn't count on that bringing you from 30fps to 60fps.

Share this post


Link to post
Share on other sites

Shared libraries introduce potential for mistakes, due to rules about memory management and library versioning. Converting static libraries to shared can lead to huge headaches. My preference is to set things up entirely as static unless I have a specific reason to want a shared library. I rarely do.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!