Error: version `GLIBCXX_3.4.21' not found - matlab

I am trying to compile matconvnet-1.0-beta20 with Matlab 2016a on Ubuntu 16.04. Initial phase of compilation works fine:
untar('http://www.vlfeat.org/matconvnet/download/matconvnet-1.0-beta20.tar.gz') ;
cd matconvnet-1.0-beta20
run matlab/vl_compilenn
The error happens when I run vl_simplenn(network, image) which gives following error:
Invalid MEX-file '/home/matconvnet-1.0-beta20/matlab/mex/vl_nnconv.mexa64':
/usr/local/MATLAB/R2016a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version
`GLIBCXX_3.4.21' not found (required by /home/matconvnet-1.0-beta20/matlab/mex/vl_nnconv.mexa64)
To understand the cause of problem, I run /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC which doesn't give any output bash: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: Permission denied
Also more /usr/lib/x86_64-linux-gnu/libstdc++.so.6 gives no output:
******** /usr/lib/x86_64-linux-gnu/libstdc++.so.6: Not a text file ********
I did some research and found some possible solutions:
http://it.mathworks.com/matlabcentral/newsreader/view_thread/162466
The problem is that MATLAB secretly changes LD_LIBRARY_PATH on startup
to point to the MATLAB version of GLIBC++, so that GLIBC++ 3.4.9 can
no longer be found. The solution is to modify matlab/bin/.matlab7rc.sh
so that "LDPATH_PREFIX" contains the path to the version of GLIB
installed with your compiler, then this is found before the
matlab-supplied library.
so I edited /usr/local/MATLAB/R2016a/bin/.matlab7rc.sh and modified LDPATH_PREFIX='' in 195th line to LDPATH_PREFIX='/usr/lib/x86_64-linux-gnu'.
After applying this change, the problem still exist.
As suggested here, I copied .matlab7rc.sh to current working directory of project, but still error persist.
https://askubuntu.com/questions/719028/version-glibcxx-3-4-21-not-found
According to first answer, running this command
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6
gives an error:
ln: failed to create symbolic link 'usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6': No such file or directory
Seems like second solution suggests changes of LD_PRELOAD path in .matlab7rc.sh, but it is not anywhere inside the file.
How to tell mex to link with the libstdc++.so.6 in /usr/lib instead of the one in the MATLAB directory?
From Matlab directory in /usr/local/MATLAB/R2016a/bin$ I run
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
but the problem still exist.
Maybe there I didn't apply the solution in the correct way Or maybe there is another solution elsewhere that I didn't find. Please let me know, I am very confused!!!

You need before execute (matlab in my case) add path of library:
In console execute this:
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab

I had the same problem.
In my case, to solve it, I first ran "locate" to list all the possible versions of the library in the system.
locate libstdc++
As an example, I report the result on my system
I then set the most recent version of "lib" by exporting the environment variable:
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21"
So, the fullpath of the library to be set depends on where it is allocated in your system.

There are 2 possible solutions:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Install this package:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
MAYBE the second solution you mentioned really works, but you have done it before. So you cannot operate in the same way again because you have ever linked /usr/lib/x86_64-linux-gnu/libstdc++.so.6 to usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6. TRY rebooting?
Also, you use MATLAB R2016a, but this command applies to R2014a. Was it that you ignore this point?

Related

Invalid MEX-file '/home/hit/caffe-master/matlab/+caffe/private/caffe_.mexa64': [duplicate]

I have been stuck on this problem for several weeks and been looking around on Internet for solution but so far not so good...
So I have a program written by someone else and I try to compile it in Matlab to make it work. My computer is Red-hat enterprise Linux workstation (64 bits) with gcc 4.4.3 and Matlab 2011b installed. The gcc is compatible with my Matlab (http://www.mathworks.com/support/compilers/R2011b/glnxa64.html).
The compilation works fine (I mean, no error message occurs in Matlab command window). But after compilation, every time when I use a specific function from the compilation (it's call "mexLasso"), it will show up errors like this:
***Invalid MEX-file '/usr/local/matlab_R2011b/toolbox/spams-matlab/build/mexLasso.mexa64':
/usr/local/matlab_R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version
`GLIBCXX_3.4.11' not found (required by
/usr/local/matlab_R2011b/toolbox/spams-matlab/build/mexLasso.mexa64)
Error in test (line 24)
alpha=mexLasso(X,D,param);*
So I type "strings /usr/lib/libstdc++.so.6 | grep GLIBC" in the terminal, and I found the "GLIBCXX_3.4.11" is actually in it.
I've been using Linux and gcc stuff for only several months...so there are still a lot of things I don't understand. It will be of great help if you can explain it in detail. Thanks!!
%% More detail:
I got these programs on machine learning from http://spams-devel.gforge.inria.fr/downloads.html. The wierd thing is, after compilation, other functions in that package works fine (such as "mexTrainDL").
The solution prompted by #whjiang works but have two limits:
You may be required a sudo privilege to change the library symbol
link.
The change is global and can affect all users
So there is another.
As explained by this answer from MATLAB Central, the problem is caused by Matlab:
Matlab internally changes the LD_LIBRARY_PATH to prefer <MatlabPATH >/sys/os/<ARCH>
and the <MatlabPATH>/sys/os/libstdc++.so.6 is out of date.
The solution is set LD_PRELOAD when calling Matlab like this,
env LD_PRELOAD=/usr/lib/libstdc++.so.6 <MatlabPATH>/bin/matlab -desktop
The path of libstdc++.so.6 my be different from os to os. For example, on my LMDE2, the path is /usr/lib/x86_64-linux-gnu/libstdc++.so.6.
This is answered in the libstdc++ FAQ: http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths
Here is an solution:
sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 /usr/local/MATLAB/R2011b/bin/glnxa64/libstdc++.so.6
explanation and reference:
http://fantasticzr.wordpress.com/2013/05/29/matlab-error-libstdc-so-version-glibcxx_3-4-15-not-found/
A simple solution from this page ( http://ubuntuforums.org/showthread.php?t=808045 ) that worked for me.
Go to the matlab directory where libstdc++.so.6 and libgcc_s.so.1 are stored. In my case, this was:
cd /usr/local/MATLAB/MATLAB_Production_Server/R2015a/sys/os/glnxa64
Then rename libstdc++.so.6 and libgcc_s.so.1:
sudo mv libstdc++.so.6 libstdc++.so.6.orig
sudo mv libgcc_s.so.1 libgcc_s.so.1.orig
That's it!

Lpsolve matlab installation error

The error is:
Error using mxlpsolve
Failed to initialise lpsolve library.
I run the
Makefile.m
in the folder and the compiliation, it says everything compiled fine. Where do i need to put mslpsolve and where do i find it?
I used the following guide to solve the same problem:
http://lp-solve.2324885.n4.nabble.com/Fwd-Re-lpsolve-in-MATLAB-on-Mac-OS-X-10-8-2-td1770.html
the only thing that was missed within the guide and I added it up is as follows:
$ cd $HOME/Documents/MATLAB/lp_solve_5.5/extra/MATLAB/lpsolve
$ sudo ln -s /opt/local/lib/liblpsolve55.dylib liblpsolve55.so
make sure that you have installed lp_solve package already.

pg_ctl: error while loading shared libraries: libpq.so.5

I'm trying to get postgres server status with:
sudo /etc/init.d/postgres status -u postgres
But getting following error:
/home/alex/olddisk/usr/local/pgsql/bin/pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
I added:
export LD_LIBRARY_PATH=""
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/alex/olddisk/usr/local/pgsql/lib/"
to my .bashrc, but it didn't help.
Thank you.
I ran into this error when I built postgresql from source using the --prefix flag. Building from source installs the necessary shared libs to the libs folder under the prefix directory you specified, instead of the usual place installations put shared libs. To solve the problem I just added the [prefix].libs folder to the LD_LIBRARY_PATH environment variable. For example, after building postgres using --prefix /mike/sandbox/postgres, the below command solved the issue:
export LD_LIBRARY_PATH=/mike/sandbox/postgres/lib:$LD_LIBRARY_PATH
I think this issue is duplicated, I faced the same problem and posted a solution here.
try this:
1: Know the path of "libpq.so.5"
find / -name libpq.so.5
Output example: "/usr/pgsql-9.4/lib/libpq.so.5" If found nothing, check if you have already installed the suitable postgresql-libs for your postgresql version and your OS platform
2: Symbolic link that library in a "well known" library path like "/usr/lib":
ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib/libpq.so.5
Attention: If your platform is 64 bit, you MUST also symbolic link to 64 bit libraries path:
ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib64/libpq.so.5
3: Be happy !
Please ensure you have 'postgresql94' package installed as well (in addition to postgresql94-server, postgresql94-lib, postgresql94-devel and whatever other PG related package you already have). These libraries get installed along with that package.
Some ideas:
Your modified ~/.bashrc only takes effect when you start a new (interactive) shell. Though catching up on that will not help you because:
/etc/sudoers, your configuration file of sudo, probably specifies env_reset. This means, that /etc/init.d/postgres will not see the content of $LD_LIBRARY_PATH of your shell.
Insert debug statements in /etc/init.d/postgres to verify what I told you: echo "LDPATH: $LD_LIBRARY_PATH" >&2
Check /etc/init.d/postgres. Probably you will have to insert the third one of your export statements near the start of this script. Or you will have to update an existing export LD_LIBRARY_PATH= statement.
Have you installed the necessary libraries?
If you are using ubuntu try:
sudo apt-get install libpq libpq-dev

How to uninstall opencv in Ubuntu?

I have the following system:
Linux 64 bit LTS 12.04
I have multiple installations of opencv library on the system.
I want to know the procedure to remove all opencv libraries from the system.
I am having trouble while executing my program through Eclipse IDE.
Though I can build the project when I try to execute it, it gives the following error:
OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in release, file /build/buildd /opencv-2.3.1/modules/core/src/matrix.cpp, line 1364
terminate called after throwing an instance of 'cv::Exception'
what(): /build/buildd/opencv-2.3.1/modules/core/src/matrix.cpp:1364: error: (-215) k == STD_VECTOR_MAT in function release
Confusing thing is I am not able to find the path specified in the error i.e.
/build/buildd/opencv-2.3.1/modules/core/src/matrix.cpp
I am able to compile the same source code using command line tool gcc and using pkg-config.
However I am unable to do the same through eclipse IDE.
You can also uninstall by going to the "build" folder directory of opencv from terminal, and execute the following
make uninstall
cd ..
sudo rm -r build
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
I remember I used this command a while ago to remove all opencv related things. It is interactive which promote you to remove the file. choose y or n depending.Take your time and be-careful
$> sudo find / -name "*opencv*" -exec rm -i {} \;
The correct way is cd /path/to/cv/build then sudo make uninstall. Of course you will have to have the source code with you
I tried the exec rm thing but nothing changed. Also FYI, sudo apt-get remove libopencv-* did not remove openCV for me

libgfortran: version `GFORTRAN_1.4' not found

I am getting the following error when I trying to a run mex file in MATLAB:
??? Invalid MEX-file
'findimps3.mexa64':
/MATLAB/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/libblas.so.3gf)
Any ideas how to solve this problem?
update:
I found out that "strings MATLAB/.../libgfortran.so.3 | grep GFORTRAN" output GFORTRAN_1.0. I tried to changed libgfortran inside MATLAB but it didn't work. Not I think it's better to find a suitable libblas that works with GFORTRAN_1.0.
read this link, it explains how to configure matlab on some linux systems.
here the steps that are relevant to you:
To enable running external programs, […] fortran libraries need to be properly updated and linked. Look at the output of this command:
ll "$MATLABDIR/bin/glnxa64/"
It is likely that [this link] exist:
libgfortran.so.3 -> libgfortran.so.3.0.0
Search for [this library] on your machine:
locate libgfortran.so
[…] Update Matlab's links to point to these newer versions:
sudo ln -sf [location of libgfortran.so.3.0.0] "$MATLABDIR/bin/glnxa64/libgfortran.so.3"
I (think I) fixed this problem by running matlab with LD_PRELOAD, like this
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libfreetype.so:/usr/lib/x86_64-linux-gnu/libgfortran.so.3 matlab
Notice freetype was another library I was having a similar problem with.
In my case the following command worked:
sudo ln -sf /usr/lib/gcc/i686-linux-gnu/4.7/libgfortran.so /usr/local/MATLAB/R2012a/sys/os/glnx86/libgfortran.so.3
Matlab was complaining it couldn't find the GFORTRAN1.4 in the following location:
/usr/lib/gcc/i686-linux-gnu/4.7/libgfortran.so
So I linked this location to the library I had :
/usr/local/MATLAB/R2012a/sys/os/glnx86/libgfortran.so.3
I found the location of this library by using the locate command as given above:) Thanks for the help:)
In my case, fixed by
$ ln -sf /usr/lib64/libgfortran.so.3.0.0 /opt/matlab/sys/os/glnxa64/libgfortran.so.3
Errors I meet when using CDSP:
csdp: /opt/matlab/sys/os/glnxa64/libgfortran.so.3: version GFORTRAN_1.4' not found (required by /usr/lib64/atlas/libptf77blas.so.3)
csdp: /opt/matlab/sys/os/glnxa64/libgfortran.so.3: versionGFORTRAN_1.4' not found (required by /usr/lib64/atlas/libf77blas.so.3)
I just ran into the same problem (error usr/lib64/libgfortran.so.3: version `gfortran_1.4' not found) and it was actually not hard to fix. The problem seems to be that gfortran_1.4 version of libgfortran.so.3 comes from the release gcc-4.6.2 (i.e. fortran 4.6).
What I did was downloaded gcc-4.6.2 and built, using the steps: tar -xvf gcc-4.6.2.tar.gz cd gcc-4.6.2 ./contrib/download_prerequisites cd .. mkdir objdir cd objdir $PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 --enable-languages=c,fortran,c++,go make make install
Then, once everything was made, I went to the directory where the new, fresh libgfortran.so.3 was sitting (in my case it was /home/testuser/objdir/x86_64-unknown-linux-gnu/32/libgfortran/.libs/)
I copied this version of libgfortran.so.3, and went to the directory where my program was expecting to find libgfortran.so.3. I replaced the old one (the old libgfortran.so.3) with the new one (the one we just copied).
The problem instantly went away. I hope this helps you too!