Matlab - dyld: Library not loaded: /usr/local/opt/mpfr2/lib/libmpfr.1.dylib - matlab

I am trying to compile a matlab program using mex. I am facing the following error and was wondering if you have any suggestions. I have installed latest version of mpfr at /usr/local/opt/mpfr but it is still picking /usr/local/opt/mpfr2.
The error is as below:
dyld: Library not loaded: /usr/local/opt/mpfr2/lib/libmpfr.1.dylib
Referenced from: /usr/local/Cellar/gcc48/4.8.1/gcc/libexec/gcc/x86_64-apple-darwin12.5.0/4.8.1/cc1plus
Reason: Incompatible library version: cc1plus requires version 4.0.0 or later, but libmpfr.1.dylib provides version 3.0.0
g++-4.8: internal compiler error: Trace/BPT trap: 5 (program cc1plus)
/Applications/MATLAB_R2012b.app/bin/mex: line 1326: 15075 Abort trap: 6 /usr/local/bin/g++-4.8 -c -I/Applications/MATLAB_R2012b.app/extern/include -I/Applications/MATLAB_R2012b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.7 -DMX_COMPAT_32 -O2 -DNDEBUG "face-detection/src/resizef.cc" -o face-detection/private/resizef.o

Try running this command before compiling:
setenv('DYLD_LIBRARY_PATH','')
I was trying to compile something else (not a Matlab program) and received the same error. The same command worked in bash, so I inspected the environment variables and found that Matlab's DYLD_LIBRARY_PATH differed from bash's DYLD_LIBRARY_PATH. The bash DYLD_LIBRARY_PATH was not defined, so I set it to empty in Matlab and it fixed the path error.
Matlab's setenv documentation:
Values assigned to variables using setenv are picked up by any
process that is spawned using the MATLAB SYSTEM, UNIX, DOS or '!'
functions. You can retrieve any value set with setenv by using
GETENV(NAME).

Try reinstalling gcc and its mpfr2 package, e.g.:
brew reinstall gcc48 mpfr2
Also make sure you're not overriding any DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH or DYLD_FRAMEWORK_PATH variables from the startup shell scripts (e.g. ~/.bash_profile).

Related

Scipy build fail on MacOS because LLVM producer != reader

I'm trying to build Scipy from source. However, a linking step...
/usr/bin/clang -bundle -undefined dynamic_lookup -L/Users/gwg/miniconda3/envs/scipy-dev/lib -arch x86_64 -L/Users/gwg/miniconda3/envs/scipy-dev/lib -arch x86_64 -L/usr/local/opt/libomp/lib -lomp -I/usr/local/opt/libomp/include -Xpreprocessor -fopenmp -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/scipy/spatial/src/distance_wrap.o -L/Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib -Lbuild/temp.macosx-10.9-x86_64-3.7 -lnpymath -o build/lib.macosx-10.9-x86_64-3.7/scipy/spatial/_distance_wrap.cpython-37m-darwin.so
...fails, and I get the following error:
ld: in /Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib/libnpymath.a(npy_math.o), could not parse object file /Users/gwg/miniconda3/envs/scipy-dev/lib/python3.7/site-packages/numpy/core/lib/libnpymath.a(npy_math.o): 'Unknown attribute kind (61) (Producer: 'LLVM10.0.0' Reader: 'LLVM APPLE_1_1000.10.44.4_0')', using libLTO version 'LLVM version 10.0.0, (clang-1000.10.44.4)' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I suspect it is due to the Producer: 'LLVM10.0.0' Reader: 'LLVM APPLE_1_1000.10.44.4_0' mismatch. But I don't know how to investigate this error.
Some details:
MacOS: High Sierra, 10.13.6
gcc --version:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
clang --version:
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I had the same issue. The suggestions here to use the conda compilers resolved the issue for me:
conda create -n scipy-dev
conda activate scipy-dev
conda config --env --add channels conda-forge
conda install numpy cython pybind11 pytest compilers openblas
python setup.py develop
It seems you're using different clang (judging from the paths like /usr/local/opt/libomp/lib). Likely the one provided by conda. In order to perform build with LTO you need to use the compatible toolchain (e.g. build everything with Apple-provided toolchain or with conda-provided one).

Unable to Install Wx - Strawberry Perl on Windows 10

While trying to install Wx for Strawberry Perl I am receiving the following error:
gcc -c -o gcc_mswudll\wxregex_regcomp.o -O2 -mthreads -DHAVE_W32API_H -DNDEBUG -I....\include -I....\lib\gcc_dll\mswu -D__WXMSW__ -D_UNICODE -m64 -MTgcc_mswudll\wxregex_regcomp.o -MFgcc_mswudll\wxregex_regcomp.o.d -MD -MP ../../src/regex/regcomp.c
../../src/regex/regcomp.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
makefile.gcc:5702: recipe for target 'gcc_mswudll\wxregex_regcomp.o' failed gmake: *** [gcc_mswudll\wxregex_regcomp.o] Error 1
system: gmake -f makefile.gcc all UNICODE=1 MSLU=0 BUILD=release SHARED=1 DEBUG_INFO=default DEBUG_FLAG=1 LDFLAGS=" -m64" CPPFLAGS="-m64": 512 at inc/My/Build/Win32.pm line 284.
MDOOTSON/Alien-wxWidgets-0.67.tar.gz
D:\Perl\perl\bin\perl.exe ./Build -- NOT OK
Stopping: 'install' failed for 'Alien::wxWidgets'.
So this actually seems to be in the compile itself? Using CPAN to install. Not sure where to go from here. Any help is appreciated.
The core problem is the line
sorry, unimplemented: 64-bit mode not compiled in
so you are using the -m64 option on a gcc that doesn't support 64-bit
Ordinarily I would expect the only gcc in your path to be the one that comes with Strawberry Perl, so are you using Cygwin or something that is causing the build to pick up the wrong compiler?

Ubuntu gcc compile errors

When I compile my program with the command
gcc -o ****** -Xlinker -Bstatic -L/usr/lib -lf2c -lm
an error occurs
usr/bin/ld: cannot find -lgcc_s
Who can tell me the way to solve this error? The version of my system is 32bit Ubuntu 13.04, gcc 4.6. And I had searched the error,somebody said it maybe the error of symlink, but it has the link of /usr/lib/libgcc_s.so to /lib/i386-linux-gnu/libgcc_s.so.1 on my system. I also setted system variable LD_LIBRARY_PATH=/lib/i386-linux-gnu, but it did not work.
It is happening when I add -Bdynamic to the command,gcc compile successfully.The commands of compiling program with archive library and dynamic library are different.Maybe it is the explanation of "cannot find -lgcc_s"

using C++11 in Mex with g++ 4.8 in linux

I'm trying to call a function I wrote in C++ 11 from a mex script. The C++ code requires -std=c++11, and runs fine from the terminal.
Here's g++ -v output: gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
I have Matlab 2013a for Red Hat.
When I first tried calling mex filename.cpp from matlab console I got:
This file requires compiler and library support for the ISO C++ 2011
standard. This support is currently experimental, and must be enabled
with the -std=c++11 or -std=gnu++11 compiler options.
So, I went into the /usr/local/MATLAB/R2013a/bin/mexopts.sh file that matlab uses to get compler options and added -std=c++11. Now I get:
cc1plus: error: unrecognized command line option "-std=c++11"
The full command gotten from mex -v filename.cpp is:
g++ -c -I/usr/local/MATLAB/R2013a/extern/include -I/usr/local/MATLAB/R2013a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -DMX_COMPAT_32 -O -DNDEBUG "mexMorph.cpp"
So, how can I get this to compile properly?
Try
mex CXXFLAGS="\$CXXFLAGS -std=c++11" simple_example.cpp
Alteratively build your mex-file without directly running Matlab such as using CMake like the following github repo : mex-it
My testing indicates that -ansi and -std=c++11 do conflict, as another responder has speculated. You could edit your mex options file (e.g. ~/.matlab/R2014a/mex_C++_glnxa64.xml in my setup) and remove -ansi.
Also note that mex accepts a -v flag, which dumps a lot of useful debugging info.
It doesn't make sense, but apparently using -std=c++0x will work. I think matlab does some checking beforehand, and since it doesn't support 4.8 officially it doesn't accept it even though the compiler would.
Can anyone back me up on this?

End of file/pseudo-op errors compiling MongoDB with SSL

I'm currently using MongoDB on Ubuntu 13.10 x64 with the replica set functionality across 3 sites and have gotten to the stage where I need to enable SSL. This requires compiling it myself and sadly I have no prior experience of this which is causing me some headaches.
I'm trying to compile r2.4.9 following the procedure outlined here: http://www.mongodb.org/about/tutorial/build-mongodb-on-linux/
I have installed a ton of packages based on what I found scouring the web for related articles:
git-core build-essential scons devscripts lintian dh-make libpcre3 libpcre3-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libpcap-dev libreadline-dev libssl-dev rng-tools
I also changed the SConstruct file to remove the CCFLAG -Werror to stop it failing immediately with so many [-Werror=unused-local-typedefs] as mentioned in this question.
The compilation process seems to get quite far but always fails at the same file dbclient_rs.cpp:
g++ -o build/linux2/ssl/mongo/client/dbclient_rs.o -c -Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -fno-builtin-memcmp -O3 -DBOOST_ALL_NO_LIB -D_SCONS -DMONGO_EXPOSE_MACROS -DSUPPORT_UTF8 -D_FILE_OFFSET_BITS=64 -DMONGO_SSL -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_EXECINFO_BACKTRACE -Ibuild/linux2/ssl/third_party/libstemmer_c/include -Isrc/third_party/libstemmer_c/include -Ibuild/linux2/ssl/third_party/s2 -Isrc/third_party/s2 -Ibuild/linux2/ssl/third_party/boost -Isrc/third_party/boost -Ibuild/linux2/ssl/third_party/pcre-8.30 -Isrc/third_party/pcre-8.30 -Ibuild/linux2/ssl -Isrc -Ibuild/linux2/ssl/mongo -Isrc/mongo -Ibuild/linux2/ssl/third_party/s2 -Isrc/third_party/s2 -Ibuild/linux2/ssl/third_party/snappy -Isrc/third_party/snappy -Ibuild/linux2/ssl/third_party/v8/include -Isrc/third_party/v8/include src/mongo/client/dbclient_rs.cpp
(warning spam removed)
{standard input}: Assembler messages:
{standard input}:73382: Warning: end of file not at end of a line; newline inserted
{standard input}: Error: open CFI at the end of file; missing .cfi_endproc directive
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
scons: *** [build/linux2/ssl/mongo/client/dbclient_rs.o] Error 4
scons: building terminated because of errors.
Note: I've also seen pseudo-op errors in the same place, but they were replaced by the above error when I removed the CCFLAG -w in favour of removing Werror instead.
Also just noticed when it starts up and does its checks the line Checking for C library rt... no - could this be a problem?
g++ version is 4.8.1, scons version is 2.3.0
Am I doing something unbelievably stupid here?
Many thanks.
Ok after more searching I found the an explanation of the problem here.
Seems to be related to not having enough RAM for the compilation process. I was running on a 512MB VPS. Worked fine after upgrading to 4GB (also removed the -pipe CCFLAG as suggested).