Docker compose libstdc++.so.6 GLIBCXX_3.4.21 not found - c++

When running docker-compose up in my node directory, I get
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node)
But I definitely have the glib:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX_3.4.2
GLIBCXX_3.4.2
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
I tried doing
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
as per https://askubuntu.com/questions/164296/glibcxx-3-4-15-not-found but I get the same error. I have no idea how to resolve this and can't find a solution anywhere else.
This is on Ubuntu 16.04 if it matters.

Some node addons on npm use node-pre-gyp to provide the ability to download pre-compiled addon binaries so that you don't need a compiler installed to use it (mainly useful on Windows, where it is usually more difficult to get a build environment set up).
For these kinds of addons, you can specify a --build-from-source command line option to tell node-pre-gyp to always compile locally instead of downloading one of the pre-compiled addon binaries.
By installing the addon with this flag, you can avoid such errors when the pre-compiled addon binaries are compiled on older/newer machines that utilize different glibc ABIs.

Related

How to install libpq-fe.h?

I cannot figure this out for the life of me.
When I pip install django-tenant-schemas it tries to install the dependency psycopg2 which requires the Python headers and gcc. I have all this installed and still keep getting this error!
./psycopg/psycopg.h:35:10: fatal error: libpq-fe.h: No such file or directory
So to install libpq-fe-h I need to sudo apt-get install libpq-dev..
..which returns..
libpq-dev is already the newest version (10.10-0ubuntu0.18.04.1).
Then when I sudo find / libpq-fe.h it doesn't seem to be in my OS.
I am lost at this point. If anyone can help I would highly appreciate it.
For some reason, the file is missing on the system.
As you're using apt-get, the system is dpkg based, presumably Debian or it's derivative. You can try the Ubuntu's package search to get which package contains a file with name ending in libpq-fe.h.
I found the package is libpq-dev and file's absolute path is /usr/include/postgresql/libpq-fe.h.
FWIW, on a dpkg based system, you can check which package gives a file if you know the file's absolute path:
% dpkg -S /usr/include/postgresql/libpq-fe.h
libpq-dev: /usr/include/postgresql/libpq-fe.h
Also, unlike find, locate keeps a cache of found files (mlocate.db) that is created everyday via cron; so if the file happens to be removed after the last run, you can run locate libfq-fe.h to get the absolute path to the file without needing to check the Ubuntu package search online.
So the package is libpq-dev. Now, reinstalling it will get everything to the default state i.e. all relevant files will be copied to the right places. As it is only a library package, no user/system level configurations will be overridden (and dpkg will prompt you for action for any package that does that).
To reinstall the package:
sudo apt-get install --reinstall libpq-dev
For me, I realized it was trying to use the deprecated setup.py so I installed wheel (pip install wheel) and that sorted it all out.
Well after installing these libraries
sudo dnf install python-virtualenv openssl-devel gcc libffi-devel libxslt-devel issue was not gone.
I used mlocate to find where libpq-fe.h file is located. On my system (Fedora 32) it was located at /usr/pgsql-10/include/libpq-fe.h
yum install mlocate
sudo updateb
locate libpq-fe.h
After all added this line to ~/.bash_profile
nano ~/.bash_profile
export PATH=/usr/pgsql-10/bin/:$PATH
Works fine, I can easily install psycopg2 without any trouble.
You need to create a LD_LIBRARY_PATH that indicates the path of your library /user/pgsql-11/lib
Source: The 3rd point of build prerequisites at https://www.psycopg.org/docs/install.html#build-prerequisites

How to install libbz2 in cross compiler g++-arm-linux-gnueabifh on Ubuntu 14.04

I am using arm-linux-gnueabihf-g++-4.8 on an amd64 machine to cross compile boost targeting ARM 32-bit architecture. My OS is Ubuntu 14.04.
It fails to build lib libboost_iostreams because libbz2 does not comes with the compiler. Following is the error detail,
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lbz2
collect2: error: ld returned 1 exit status.
Having a hard time figure out how to install this libbz2 for arm-linux-gnueabihf-g++-4.8. Did not find much document online. Need some help. Thank you very much!
I'd install libbz2-1.0:armhf from Debian jessie repository.
Actually, it is present in the Ubuntu repositories too.
Configure package manager to manage ARM packages:
sudo dpkg --add-architecture armhf
Ubuntu 14.04 codename is 'trusty', so add ARM repositories for trusty by adding the line to the /etc/apt/sources.list file:
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main
Then update package index:
sudo apt-get update
Install libbz2 for ARM (but abort if it asks to remove any packages):
sudo apt-get install libbz2-1.0:armhf
If apt-get asks to remove half of the system in order to install something big like libc6:armhf, libgcc:armhf, build-essential:armhf etc. then there is a dependency resolution session ahead. There is no precise guide to that.
Also, one minor thing: you may want to add [arch=amd64,i386] annotations to all other repositories in /etc/apt/sources.list to avoid warnings.

Compile program for 32bit on 64bit Linux OS causes fatal error

Using
gcc -m32 myprog.c
should compile in 32 bit version the file myprog.c.
Unfortunately I get this error:
In file included from /usr/include/stdio.h:27:0,
from myprog.c:1:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
How could I fix this?
If I don't use -m32 it works but uses 64 bit instructions.
To compile 32 bit binaries on 64 bit Linux version, you have to Install libx32gcc development package and 32 bit GNU C Library
try this
sudo apt-get install libx32gcc-4.8-dev
and
sudo apt-get install libc6-dev-i386
You need gcc multilib support. Install the package gcc-multilib. E.g.:
sudo apt-get install gcc-multilib
I encountered to this same problem. when I was trying to build 32 bit so file while i'm in 64 bit ubuntu version.
you can build by switching your lib version into 64 bit
in netbeans
(-> project properties -> C compiler -> additional options) set to
-shared -m64
To fix the issue we first need to know which package will provide the file sys/cdefs.h
In CentOs/RHEL based system you can find it by running below command
yum provides '*sys/cdefs.h'
Similarly, in Debian/Ubuntu systems you can find it by running
apt-file search 'sys/cdefs.h'
Note: If apt-file package is not already present on the system install it with command
apt-get install apt-file
Both above commands will scan the respective package management systems database i.e RPM/Apt and tells the name of the package which supplies the file ending with "sys/cdefs.h".
Install the appropriate package from the packages listed by the commands.
Like
On CentOs/RHEL:
yum install glibc-headers
On Debian/Ubuntu
apt-get install libc6-dev
This approach is not only useful for this particular issue but any similar issue which is reporting some required file being provided by some package being not present.

Install boost version 1.40

I am using a server running with Ubuntu 12.04
I want to install the boost libraries in it. I know
sudo apt-get install libboost-all-dev
will make the work done, but it installs the latest version version 1.52 or above.
But I need to install the particular version 1.40 as there is a problem in a simulator which I am using for my academic purpose. What is the particular command for that so that I can install the boost libraries along with the other requirements for it like the linking files
Thanks in advance
Quick answer: sudo apt-get install libboost-dev= 1.40.0.1
If it doesn't work, continue reading.
The apt-get does support installing a particular version of a package as long as it is in an archive that apt knows about. From the apt-get manpage:
A specific version of a package can be selected for installation by following the
package name with an equals and the version of the package to select. This will
cause that version to be located and selected for install. Alternatively a specific
distribution can be selected by following the package name with a slash and the version of
the distribution or the Archive name (stable, frozen, unstable).
For e.g. if you wanted to install apache 2.20 for Ubuntu, you would do something like:
sudo apt-get install apache2=2.2.20-1ubuntu1
Note that you may need to do some dependency resolution on your own in this case, but if there are any problems apt-get will tell you what is causing them. For e.g.(on 11.04)
sudo apt-get install apache2=2.2.20-1ubuntu1 \
apache2.2-common=2.2.20-1ubuntu1 \
apache2.2-bin=2.2.20-1ubuntu1 \
apache2-mpm-worker=2.2.20-1ubuntu1
Note: You must first check if build 1.40 is still available. For that use:
aptitude search libboost
If aptitude search command don't give you sufficient results, try sudo aptitude update and then run aptitude search again.
You might have to investigate whether debs from earlier Ubuntu versions can be installed. i.e. remove the current package, download the debs and try installing them. But there could be dependency on older versions of the standard library.If so, you can probably try downloading the source from launchpad.
As a last resort, download from boost.org and build it - painfully!
EDIT: I see you have asked the same question on ubuntu forums and it seems that you have 1.48 as the default. You might have to build the library itself. Can you try this apt-get
sudo apt-get install libboost1.40-all-dev=1.40.0-4ubuntu4
If this doesn't work, you will have to build it and install it yourself. You can download the source from
Download source (1.40.0): libboost 1.40.0 source files
After it's installed, run the following command to hold your installed version, preventing the package manager from automatically updating it in the future:
sudo echo "[packagename] hold" | sudo dpkg --set-selections
Source:How to Downgrade Packages on Ubuntu
Generally you download sources, build it (some parts are not just headers like filesystem on Windows). Then you can select which subset of libraries you want to install (you can make compact version with only what you need). Then by invoking bootstrap script you build it to another directory this subset of libraries you want and then you invoke install.
Here is a pretty good description how to do it: http://ubuntuforums.org/showthread.php?t=1180792

Having issues running Django with Postgres [duplicate]

I did a simple pip install psycopg2 on mac system. It installed fine, but when I try to use psycopg2 I get the error:
Reason: Incompatible library version: _psycopg.so requires version 1.0.0 or later, but libssl.0.9.8.dylib provides version 0.9.8
pip freeze shows psycopg2==2.4.5 just right. I have installed psycopg2 on several virtualenvs but this is the first time I am seeing such error. I tried uninstalling and reinstalling, same results. Please help
The accepted answer here is correct (except I think it must be ln -fs , in fact I think it might even risk destabalizing your OS if not (?)). After bumping into this and dealing with it I just want to collect the full solution for this issue and the other lib problem (libcrypto.1.0.0.dylib) you will run into for Postgres 9.* on Mountain Lion and Snow Leopard, and perhaps other systems. This also blocked me from running psql, which complained about the same two libs.
Essentially there are two later-version libs needed in /usr/lib, libssl and libcrypto. You can find the needed versions of these libs in the Postgres lib directory.
If you're OSX and installed the Enterprise DB version of Postgres this will be in /Library/PostgreSQL/9.2/lib.
For other install types of Postgres, look for the lib directory inside the Postgress install directory, e.g., for Postgress.app, find the lib directory in /Applications/Postgres.app/Contents/MacOS/lib,
for brew somewhere in /usr/local/Cellar,
on *nix, wherever your install is. But see first on *nix if your distro has later versions just through the package manager.
First copy the latest of these two libs from the Postgres lib directory to /usr/lib:
sudo cp /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib /usr/lib
sudo cp /Library/PostgreSQL/9.2/lib/libcrypto.1.0.0.dylib /usr/lib
Then update (or create) the /usr/lib symlinks for this libs. Either way the command is ln -fs:
sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
Should be fixed. Pretty sure ln -fs is better than deleting the symlink and remaking it, so there is less chance of libssl being unfindable by something that needs it for the time it is not present (it does the same thing; it first deletes the symlink if it's already there, just faster than you can type it). Always wary of messing around on /usr/lib.
Worked for me:
env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib
-L/usr/local/opt/readline/lib' pip install psycopg2
Source: Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7
I ran into a similar problem after upgrading to Mountain Lion.
Instead of copying libssl.* files per Slack's suggestion, make sure that /usr/lib/libssl.dylib is actually a soft link to the most up-to-date version of the library.
E.g., on my machine, ls -l /usr/lib/libssl* gives:
lrwxr-xr-x 1 root wheel 46B Jun 27 15:24 /usr/lib/libssl.1.0.0.dylib -> /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 27B Jul 30 10:31 /usr/lib/libssl.dylib -> /usr/lib/libssl.1.0.0.dylib
If libssl.dylib doesn't link to the version that the error version mentions, make sure you have that version of the library, and then make sure /usr/lib/libssl.dylib points to it, and not an older version.
If the link doesn't exist, create it like so
sudo ln -s library_to_link_to link_to_create
using, of course, the proper locations for your machine. For me, this turned out to be:
sudo ln -s /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
Edit:
It seems like some are having trouble with part of my solution. Namely, deleting these important libraries even temporarily causes problems with the operating system.
Per Purrell's answer, make sure you include the -fs flags when you use the ln command, which helps ensure that the libraries don't go missing for a short period of time. E.g.,
sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
On OSX 10.11, El Capitan, solution with replacing symlinks reported Operation not permitted. Solution that worked for me was using brew and setting up DYLD_LIBRARY_PATH. So:
brew install openssl
Find where openssl brew libs are located (brew --prefix openssl can help), start searching from directory /usr/local/Cellar/openssl. In my case it is in /usr/local/Cellar/openssl/1.0.2d_1/lib
Finally set up DYLD_LIBRARY_PATH, i.e. add a line like this into .bash_profile :
# replace location of lib files with folder name you found in previous step
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/openssl/1.0.2d_1/lib
UPDATE: More generic/better alternatives are (thanks to #dfrankow):
to use brew to find openssl location (a note, brew can be slow): DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(brew --prefix openssl)/lib
for development purposes maybe it is better to use DYLD_FALLBACK_LIBRARY_PATH instead - check this
Restart shell, or just source ~/.bash_profile, reinstall psycopg2:
pip uninstall psycopg2
pip install psycopg2
and test if it works:
$ python -c"import psycopg2 ; print('psycopg2 is now ok')"
When trying to do a syncdb Postgres 9.1 and /psycopg2/_psycopg.so added a further error:
Library not loaded: #loader_path/../lib/libcrypto.dylib
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8
Solved by copying these six (6) files from:
LOCAL:/Library/PostgreSQL/9.1/lib/
libssl.1.0.0.dylib
libssl.a
libssl.dylib
libcrypto.1.0.0.dylib
libcrypto.a
libcrypto.dylib
to: LOCAL:/usr/lib
This was on Mac OSx 10.8.1 with a web in a virtualenv (1.8.2) and pgAdmin (1.14.3). Inside the virtualenv is:
Django==1.4
psycopg2==2.4.5
... etc... and now back to normal.
For me, the libcryto and libss version 1.0.0 resides below:
/Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib
/Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
so the commands that fix my problem is:
sudo ln -fs /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
my friend, just copy libssl.* files from PostgreSQL lib directory to /usr/lib and relaunch your application in this case all things will be perfect ^_^
For me on Mavericks, it worked to just copy the two dylib and relaunch Python:
cp /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib /usr/lib/
cp /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib /usr/lib/
If you are uncomfortable copying libraries into your system directory, you can use the DYLD_LIBRARY_PATH environment variable to force the OS to search Postgres's library directory for libssl. E.g.:
$ DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.4/lib pip install psycopg2
(documented under the dyld man page).
I had similar problem on my Mac OS High Sierra.
ImportError: dlopen(/Users/chicha/Projects/CTMR/sample_registration/romans_env/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
But after "pip install postgres" it's work fine.
According to pip show - "postgres is a high-value abstraction over psycopg2".
While installing it's also installed psycopg2-binary and psycopg2-pool.
So, all together they have repaired the situation somehow.