How to downgrade the gcc compiler? - matlab

I have to run a code. The code includes mex files. For building that code, it required gcc version of 4.4.
Following is the description of system
Windows 10
Visual Studio 2012
Matlab 2017a
And gcc version of my system is:
$gcc --version
gcc --version
gcc (GCC) 7.4.0
I do not know how to downgrade it. I have tried so many steps, but no use.

You'll need to install it first - Please use a previous question on the subject here:
Next - choose to use it on Matlab via :
mex -setup

#mano Here's my output of the mex -setup

Related

Matlab 2015a set mingw64 as mex compiler

I have Matlab2015a 64bit running on Win7 and I want to use Mingw-w64 compiler for mex files but the command *
mex -setup
says
MEX configured to use 'Microsoft Visual C++ 2012 (C)' for C language
compilation.
I have installed Mingw-w6 compiler in
C:\mingw-w64\x86_64-4.9.2-win32-seh-rt_v4-rev4\mingw64\bin
I even had a look at this question, but I could'n solve it.
How can I switch to Mingw gcc compiler?
To see which compilers are supported by your MATLAB version and OS go to
mathworks.com/support/compilers/VERSION/index.html
where VERSION is your version. i.e.
mathworks.com/support/compilers/R2015a/index.html
If a compiler is not there, then you can not use it. In your case, its not there.

How to install libsvm in matlab

I'm using windows 7 and Matlab_R2011a. I'm trying to install LibSVM in these environments. I already installed Command Line Tools and I am trying to "make" file (go to unpacked folder of LibSVM on my Desktop, go to folder matlab and run "make"). However, I receive a compilers options as 0 and 1 but I couldn't find visual studio compiler even though I installed VS 2012
Your compiler version may not be supported/compatible with MATLAB R2011a.
First check Matlab page 'Supported and Compatible Compilers – Release R2011a' and then specify the version number.
For ex,if g++ X.Y is supported, replace CXX = g++ in the Makefile with CXX = g++-X.Y

why didn't my g++ and gcc version get upgraded?

I am on a Mac. I updated my OSx to Yosemite. I updated my xcode to version 6. I downloaded the command line tools.
And still, whenever I type in g++ --version, I get:
# g++ --version
couldn't understand kern.osversion `14.1.0'
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
meaning, I am still using the old version of g++ and gcc.
Why wasn't it upgraded? I am interested in using c++0x in Eclipse, and for that I need a newer g++/gcc compiler.
EDIT: following the comment below, I have two questions:
Why
$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
do I still seem to have an old version of clang?
Why didn't the installation of xcode and the command-line tools create the proper links to clang?
It looks like you maybe have an old version of xcode also installed.
From the command line you can switch to the proper one with
xcode-select --switch <path>
You should see something like this
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
I had a similar problem installing ios-deploy after upgrading to yosemite. i was getting the same
couldn't understand kern.osversion `14.1.0'
for gcc. I ultimately solved it by:
cd /opt/local/bin/
sudo rm gcc
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/gcc gcc
This correctly pointed gcc to the the version provided by Xcode 6.1.

How to choose a specific MinGW installation for eclipse CDT

I am using 32-bit eclipse CDT Kelper to manage a piece of code, which I could compile on command line but not with eclipse if I use any up-to-date c++11 feature. CDT tells me that "-std=c++11" is unrecognized.
After turning on the verbose option in project properties\settings\tool settings, I found that eclipse CDT somehow chooses an older version of MinGW that comes with Haskell platform 2013.2:
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\vaomp_bnb.o' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/haskell platform/2013.2.0.0/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1plus.exe -quiet -v -iprefix c:\haskell platform\2013.2.0.0\mingw\bin\../lib/gcc/mingw32/4.5.2/ -dD ..\src\vaomp_bnb.cpp -quiet -dumpbase vaomp_bnb.cpp -mtune=i386 -march=i386 -auxbase-strip src\vaomp_bnb.o -g3 -O0 -Wall -version -fmessage-length=0 -o C:\DOCUME~1\ting\LOCALS~1\Temp\ccWNoh7I.s
GNU C++ (GCC) version 4.5.2 (mingw32)
I searched SO, and there is a similar question a half year ago here. But the answer there was about setting environment variables and didn't solve the problem.
In my case, CDT can find a MinGW GCC, but found the wrong one. I have installed tdm-gcc 64 bit with gcc-4.8.1, and Haskell platform. The tdm-gcc has priority and
gcc --version
on both DOS and MSYS shows
gcc.exe (tdm64-2) 4.8.1
I don't know what heuristic does CDT use to find toolchains. My question is, how can I tell CDT to use the gcc in a specific location, e.g. c:/MinGW?
Note, I can't uninstall the Haskell platform version of gcc as I will need HP.
Thanks,
I figured it out. It seems that Eclipse CDT does not take tdm-gcc MinGW 64-bit because eclipse itself is 32-bit. So it picked up the only 32-bit MinGW it can find, which is the old version from HP.
To verify this, I installed java 1.7 64-bit, and downloaded 64-bit version of Eclipse CDT (Kelper). Now, CDT automatically selects the TDM-GCC 64 version of MinGW gcc.
For those in a similar situation, one additional issue is that the 64-bit CDT - MinGW64 combination combination does not build projects. No binary/executable files are generated even for a newly created HelloWorld c++ project (even though compilation is OK). In my case, I changed the build tool in the project properties..\tool chain. from CDT internal builder to either of the other two options (one is Gnu's and another is a long name), and then the project can be successfully made to generate exe files.

Cannot find lg2c

I'm trying to create mex for matlab from some cpp and fortran files. They all compile well and creates the .obj file. But during linking I get the error lg2c not found.
I have matlab 2007 installed in win vista. I also have mingw and gnumex installed.
The mex -setup in matlab returns 2 compilers lcc and VS 2003
I'm using G77 fortran compiler
Followed instructions in http://www.cs.ubc.ca/~pcarbo/Compile_LBFGSB_on_Windows.txt
Fortran programs compiled with g77 (as provided by GCC <= 3.4.6) need to link with libg2c. Fortran programs compiled with gfortran (as provided by GCC >= 4.0.0) need to link with libgfortran. In any case, the compiler driver (whether g77 or gfortran) ought to do that for you.
Now, the question is: is there a reference to libg2c in the Matlab-provided files. If so, you have no choice but to provide libg2c. You can find a download there.