Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell a library was compiled using C++11

How can I tell if a certain c++ library was linked using c++11 standard?

like image 397
kroiz Avatar asked Oct 29 '15 06:10

kroiz


People also ask

How do I know if I am using C ++ 11?

To see if your compiler has C++11 support, run it with just the --version option to get a print out of the version number. Do this for whichever compiler(s) you wish to use with Rosetta. Acceptable versions: GCC/g++: Version 4.8 or later.

How do I know if G ++ supports C ++ 17?

C++17 Support in GCC C++17 features are available since GCC 5. This mode is the default in GCC 11; it can be explicitly selected with the -std=c++17 command-line flag, or -std=gnu++17 to enable GNU extensions as well.


1 Answers

An elf binary would by default contain the signature of compiler version used.

Now, with regards to compiler flags used, If -frecord-gcc-switches is used at compile time, then, you can find the signature in ELF executable.

 g++ -frecord-gcc-switches -std=c++0x trial.cpp
readelf -p .GCC.command.line a.out

String dump of section '.GCC.command.line':

  [     0]  -imultilib . [     d]  -imultiarch x86_64-linux-gnu   [    2a]  -D_GNU_SOURCE   [ 38]  trial.cpp   [    42]  -mtune=generic   [    51]  -march=x86-64  [    5f]  -std=c++0x   [    6a]  -frecord-gcc-switches   [    80]   
-fstack-protector
like image 179
basav Avatar answered Sep 30 '22 16:09

basav