Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do we need to recompile libraries with c++11?

This is a very uninformed question, but:

I would like to start using C++11. Can I continue to use my large collection of libraries which were compiled with my old gcc 4.2.1 compiler or do I need to recompile them all with a new compiler? I would think (or hope) the answer is no, but I am only a dabbler.

So that I may have at least part of my ignorance removed, can you explain why in either case?

Thanks

like image 860
user487100 Avatar asked Feb 23 '12 07:02

user487100


People also ask

Are libraries already compiled?

Libraries are precompiled for several reasons. First, since libraries rarely change, they do not need to be recompiled often.

Can you use C without libraries?

If you disassemble the program, you can see only your code is there, there is no standard library bloat in it. So you can use C without the standard library.

Is the C standard library written in assembly?

The standard libraries are typically written in C and C++, using a bare minimum of assembly code in order to interact with the functionality provided by the operating system, and most operating systems are written in C as well as a mix of assembly for a handful of things that cannot be done directly in C.

What is the use of c++ library?

The C++ Standard Library provides several generic containers, functions to use and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and functions for common tasks such as finding the square root of a number.


Video Answer


1 Answers

Yes, you should.

The weaker reason is not binary compatibility, the problem is about expectations. A C++11 enabled compiler will expect a number of features to be available (move constructors among them) and use them when appropriate. And that's only scratching the tip of the iceberg, there are several other incompatibilities (auto, 0 and its interaction with pointers, ...).

It means that any inline method in a header may suddenly be interpreted differently, in light of the C++11 Standard.

The stronger reason is that each version of the compiler comes with its own Standard Library implementation. You don't really want start mixing various versions around and especially not when they have undergone such major changes (once again, rvalue references...).

Believe me, it's simpler to recompile now rather than having that nagging thought that each bug that appear may be due to an incompatibility between old and new libraries...

like image 178
Matthieu M. Avatar answered Oct 01 '22 18:10

Matthieu M.