GLIBCXX not found when compiling vtk example under mex - c++

I have been trying to follow this example for compiling vtk in MATLAB using mex, on an Ubuntu 11.10. The mex command I used is as follows:
mex -I/usr/include/vtk-5.6 vtk_file.cpp -L/usr/lib/ -lvtkFiltering -lvtkRendering -lvtkCommon
After compilation I have a .mexa64 file.
However, when I try to run the file I end up with the following error:
Invalid MEX-file '/home/bill/Documents/MATLAB/vtk/vtk_file.mexa64':
/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.11' not found (required by /usr/lib/libvtkFiltering.so.5.6)
How can I ensure that glibcxx is found? I would have assumed that it would be included by default in the compilation.

Matlab uses its own glibc librarires, and it's often a big mess because of that.
To solve that problem you should first try to ensure that matlab use a supported version of gcc. Do you get a warning about that when you compile?
If you are sudoer, you can also "force" matlab to use the standard glibc, by doing something like that (I did it, and it works fine):
cd /usr/local/MATLAB/R2011a/sys/os/glnxa64
sudo mkdir old
sudo mv libstdc++.so.6* old
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
Many people complain about that on the internet, there are different solutions, if those two ones don't work.

Related

Having problems with gdb [duplicate]

How can I include/view the source code of malloc in gdb?
I want to do a step by step execution in gdb, and step into malloc.c source code when any of the malloc functions is called.
Currently what gdb says is:
malloc.c: No such file or directory.
This guy here faced the same problem, but they do not mention a solution, ie how to actually step into the source code of malloc.
I am on Ubuntu server 14.04, and I have already tried to install the following:
libc6-dbg, libc6-dev, and libc6-dbgsym.
I don't even know if one of these packages might help, but installing the libc-dbgsym gives me the following error:
dpkg: error processing archive /var/cache/apt/archives/libc6-dbgsym_2.19-0ubuntu6.6_amd64.ddeb (--unpack): trying to overwrite
'/usr/lib/debug/usr/lib/x86_64-linux-gnu/audit/sotruss-lib.so', which
is also in package libc6-dbg:amd64 2.19-0ubuntu6.6 dpkg-deb: error:
subprocess paste was killed by signal (Broken pipe)
The following worked for me. Not sure whether there is a better way.
Install libc6-dbg (which you have already done):
sudo apt-get install libc6-dbg
Install the eglibc-source package (ubuntu actually uses eglibc): sudo apt-get install eglibc-source.
Unpack the tar file that was installed in /usr/src/glibc: /usr/src/glibc $ sudo tar xvf eglibc-2.19.tar.xz
Crank up gdb and add in the path to the malloc source: (gdb) dir /usr/src/glibc/eglibc-2.19/malloc
(gdb) n
13 char *c = malloc(100);
(gdb) s
__GI___libc_malloc (bytes=100) at malloc.c:2876 2876
{
(gdb)
Gdb can only show the source codes because the debug-compiled binaries contain references between the binary code and the source files.
malloc() is in the C library. On normal systems, it is not compiled with debug metadata, and its sources are also not installed in the system.
But they are reachable, you only need to install the debug versions of these libraries. For example, on debian an apt-get install glibc-debug or similar will do it. On SuSE, a zipper in libc6-debug (afaik, maybe the exact package names could be a little bit differ).

gcc returns "No such file or directory"

I'm trying to install Mathtex on my Ubuntu 16.04 server for my engineering wiki. It has been a nightmare, just as it was in the past when I tried this.
First, I've installed mathtex via apt-get. That complains of a missing directory. After manually creating those directory it moves on to complain of another. Finally complains of a missing cache directory. I create the cache just like the others and mathtex still complains that the cache directory is missing...
Then I attempt to install via the instructions on the website (http://www.forkosh.com/mathtex.html). In other words, install the dependencies LaTeX and dvipng. Then compile the program using cc (although I use gcc). I've gotten this to work in previous installations of Ubuntu - 12.04 or 14.04 - but can't find those instructions anymore. I was paying for a service until this summer when they went out of business.
Here is the compile line:
cc mathtex.c –DLATEX=\"$(which latex)\" –DDVIPNG=\"$(which dvipng)\" –o mathtex.cgi
Here is the return:
cc: error: –DLATEX="/usr/bin/latex": No such file or directory
cc: error: –DDVIPNG="/usr/bin/dvipng": No such file or directory
cc: error: –o: No such file or directory
I've also tried replacing $(which latex) with $(which pdftex) (/usr/bin/latex is a symbolic link to /usr/bin/pdftex) and /usr/bin/pdftex, /usr/bin/tex, /usr/bin, and /usr/bin/. Same result, the error says there is no such file or directory for all of them.
Googling this error only returns help for people who can't get Ubuntu to recognize gcc as the cc compiler. That's not my issue though.
Did you copy that command from a document? You have the wrong kind of dashes on your options.
Delete the – (en dash) and replace it with -.

Protobuf 3.0.0-alpha-1 not compiling on windows

I'm trying to compile protobuf 3.0.0 alpha 1 on Windows using MinGW 4.9.2 & MSYS.
According to the instructions I'm supposed to:
./configure
make
make check
make install
I added --prefix=/c/path/to/mingw to configure (How to build Google's protobuf in Windows using MinGW?) but it didnt help.
It fails at make with the message:
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /home/Markus/protobuf-3.0.0-alpha-
1/missing aclocal-1.14 -I m4
/home/Markus/protobuf-3.0.0-alpha-1/missing: line 81: aclocal-1.14: command not
found
WARNING: 'aclocal-1.14' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
I've tried installing Automake but it doesnt come with aclocal.
Also today at work i managed to get it working on the first try with a bare MinGW & MSYS.
It looks like you need to install autoconf (which is separate from automake, though they are often used together). You may also need to install libtool.

g++ 4.6 issue no <bits/c++config.h> file as required by the header cstring

There is no file called bits/c++config.h in the c++ include directory which is required by the cstring header file. But when I include the the header cstring and compile with g++, it does not give me error. The problem occurred when I tried to compile the program with clang++ compiler in the following way.
$clang++ -cc1 -I/usr/include -I/usr/include/c++/4.6.1 -I/usr/lib/gcc/i686-linux-gnu/4.6.1 -I/usr/include/i386-linux-gnu -I opt_149739_build/include hello.cpp
In file included from /media/space/hello.cpp:2:
In file included from /media/space/opt_149739_build/include/clang/Driver/Driver.h:13:
In file included from /media/space/opt_149739_build/include/clang/Basic/Diagnostic.h:17:
In file included from /media/space/opt_149739_build/include/clang/Basic/DiagnosticIDs.h:18:
In file included from /media/space/opt_149739_build/include/llvm/ADT/StringRef.h:14:
/usr/include/c++/4.6.1/cstring:42:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>
I am using g++ 4.6.1 on Ubuntu 11.04
What went wrong?
The file bits/c++config.h is the platform specific include relative to the current compiler, so it is hidden in another directory, searched by default by g++, but not by clang++, as it seems.
In my machine, running locate c++config.h gives the following (relevant) files:
/usr/include/c++/4.6/i686-linux-gnu/64/bits/c++config.h
/usr/include/c++/4.6/i686-linux-gnu/bits/c++config.h
The first one is for 64-bits and the second one for 32-bits.
So just add -I/usr/include/c++/4.6/i686-linux-gnu or -I/usr/include/c++/4.6/i686-linux-gnu/64 or whatever you need for your platform.
Ran into the same problem while cross-compiling, the problem was solved after installing libstdc++-10-dev for arm. If you are not cross-compiling then you can try installing latest libstdc++ pkg.
sudo apt-get update
sudo apt-get install libstdc++-10
Then you may run into a header error: ' asm/errno.h' file not found. Just install gcc-multilib for this.
sudo apt install gcc-multilib
It can be related to how clang++ search its headers files.
You'll find a sample patch of how they fix it for fedora 15, 4 months ago, here.
See this red hat bugzilla post for more info.

Trying to install OCaml 3.12.1 on Linux with Godi

I'm trying to install OCaml 3.12.1 on 64 bit Linux (Mint Linux which is essentially Ubuntu 11.04). I'm using the latest rocketboost (godi-rocketboost-20110717). I run ./bootstrap and after a while get the following (in bootstrap.log):
4287 ### Building godi-pcre
4288 ===> Cleaning for godi-pcre-6.2.2godi1
4289 => Checksum mismatch for pcre-ocaml-6.2.2.tar.gz.
4290 Make sure the Makefile and checksum file (/home/phil/godi-3.12.1/build/godi/ godi-pcre/distinfo)
4291 are up to date. If you want to override this check, type
4292 "godi_make NO_CHECKSUM=yes [other args]".
4293 Error: Exec error: File /home/phil/godi-3.12.1/build/godi/godi-pcre/./../../ mk/bsd.pkg.mk, line 1689: Command returned with non-zero exit code
4294 Error: Command fails with code 1: godi_console
Is this a package problem with pcre?
And how would I use the suggest "godi_make NO_CHECKSUM=yes [other args]" to fix this?
This has been fixed by the maintainer of the pcre-ocaml library. It should work fine now.