2

I am doing some research whether to compile C++ libraries static or dynamic for a new project. (I have read this answer, also). I saw that on OpenBSD and FreeBSD the system libraries are a lot bigger (5-7 MB) than on Linux (1.5 MB) because they are not stripped. So I have 2 questions:

  1. The OpenBSD libestdc++.so is any different than libstdc++.so? I didn't find any info on it, google just corrects me, removing the "e" letter from the word.
  2. Why these libraries are so big on BSD? If I would like to deploy or statically link them they will be huge. Is there a workaround for this?

Thank you.

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
Taw
  • 479
  • 3
  • 15
  • What version of FreeBSD are you talking about? Because FreeBSD 10 seems to use LLVM `libc++` instead. – Nazar554 Feb 13 '17 at 11:23
  • I am using FreeBSD 10.3 and it seems that gcc is using stdlibc++, not libc++. I created a simple C++ 14 binary and these are its dependencies: libstdc++.so.6 => /usr/local/lib/gcc49/libstdc++.so.6 (0x800820000) libm.so.5 => /lib/libm.so.5 (0x800b33000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800d5c000)libc.so.7 => /lib/libc.so.7 (0x800f6a000) – Taw Feb 14 '17 at 08:12

1 Answers1

2

On OpenBSD, libstdc++ is the base c++ library (GCC 4.2), libestdc++ is installed from ports (GCC 4.9 or 6). The libraries are installed with symbols on OpenBSD, you can strip the symbols with strip -s libwhatever.so.

Rufo El Magufo
  • 686
  • 6
  • 19
  • Thank you for the answer. I saw that I can strip the symbols but my concern was whether I will "break" (our build machines are used by many teams) anything if I will do this. Or perhaps I can make a duplicate of libestdc++, strip it and link my binary with the stripped one? – Taw Feb 13 '17 at 12:13
  • You will not break the dependencies of the lib. However, the package tools will complain due to the different checksums. My suggestion is to use a virtual machine to strip and link statically the libs and then to move those to production. – Rufo El Magufo Feb 13 '17 at 15:09