Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC runtime libraries vs Microsoft Visual C++ runtime redistributables

Could anyone shed some light on C++ library versioning and distribution of

  • GCC library (libgcc, libstdc++,..?)
  • Microsoft Visual C++ runtime libraries (6.0, 2005, 2008, 2010, 2012, 2013, 2015,....)

With my limited exposure to GCC programming, I have never seen C++ runtime libraries being distributed along with program. That is often the case with MS Windows programs.

Can a relatively old linux system run a newer C++14 program (which is compiled on a newer system and then copied over to old system)?

Do GCC programmers distribute runtime libraries along with programs? If no, Why do Windows programs distribute them? How GCC distributions ensure that a C++ program always works when installed?

What about the frameworks such as Qt, How does Qt handle versioning and distribution on Linux and Windows? Does Qt also distribute runtimes for different versions?

May be it has to do with platform, how Linux is designed vs How Windows is designed.

What is so fundamentally different in approaches GCC & MS Windows take?

like image 976
user1 Avatar asked Sep 22 '15 08:09

user1


People also ask

Is Visual Studio better than GCC?

When comparing GCC vs Microsoft Visual C++, the Slant community recommends Microsoft Visual C++ for most people. In the question“What are the easiest to use C++ compilers and IDEs?” Microsoft Visual C++ is ranked 2nd while GCC is ranked 3rd.

Is Microsoft Visual C++ redistributable necessary?

We don't recommend that you delete any Visual C++ redistributable, because doing so could make multiple applications on your computer stop working. Given how little space they take up and how broadly they are used, it doesn't seem worth the hassle to mess with your current ecosystem of standard library files.

Should I install all C++ redistributables?

When doing a fresh Windows OS install, it's recommended to always install all the various C++ runtimes, which is why this all-in-one pack was created.

Do I need to keep all versions of Visual C++?

When you install a program that requires a specific version of Microsoft Visual C++, it will automatically install it first before installing the program. I wouldn't advise you to delete or uninstall any of those as we are not sure of what programs are using them.


1 Answers

GCC's runtime libraries, like GNU's C library, provide a stable binary interface (small footnote: GCC 5.1 kind of blew this up, due to new C++ features that had to be implemented). Microsoft's libraries don't, and each little version difference may and probably will break the ABI (application binary interface). Additionally, Microsoft compilers change their ABI with version increments as well, making it a bad idea to combine code built by different versions of their tools. Also here, GCC maintains a strict ABI, which makes object code perfectly compatible (if no ABI breaking codegen options are given of course).

This ABI consists of object size and layout, which a compiler uses when generating code. Therefore running code built against one version but using a different version at runtime may produce unexpected results because the memory layout and use is just different.

GNU/Linux is quite strong in this regard, and is generally able to maintain strong backwards compatibility. As long as the compiled program was compiled against an older version of the library, it will run perfectly if loaded with a newer version that a user has installed. The same story goes for Qt, which only breaks ABI between major version numbers (Qt 4 and Qt 5 cannot be loaded at runtime interchangeable).

There are some small exceptions, GCC 5's libstdc++ being a big problem there. I know of no big glibc ABI breakages though. The new Microsoft Universal CRT attempts to solve this issue, by providing a stable C runtime interface and as the story would have us believe, provide a glibc style library ABI stability. This UCRT is available for Windows Vista and up, but applications need to be compiled specifically against this. The first version of VS that has this capability, is VS2015.

like image 65
rubenvb Avatar answered Oct 22 '22 17:10

rubenvb