cplex would not run on matlab due to invalid mex-file - matlab

I'm trying to use cplex on matlab but I'm getting the following error:
Error using cplexlp (line 256)
Invalid MEX-file 'C:\Program
Files\IBM\ILOG\CPLEX_Studio1271\cplex\matlab\x64_win64\cplexlink1271.mexw64': The specified
procedure could not be found.
Error in cplex_example (line 12)
[x,fval,exitflag,output] = cplexlp(f,A,b,Aeq,beq,lb,ub,options);
I have already added the paths as follows:
addpath ('C:\Program Files\IBM\ILOG\CPLEX_Studio1271\cplex\matlab\x64_win64')
addpath('C:\Program Files\IBM\ILOG\CPLEX_Studio1271\cplex\examples\src\matlab')
savepath
My laptop runs on Windows 10 64-bit, my matlab is R2013a 64-bit and cplex is cplex 12.7.1 win-x86-64.
I saw an answer to a similar question and they said it must be checked by dependency walker. Dependency walker showed that a whole bunch of API-MS-WIN-CORE, EVENTING, SECURITY, SERVICE, EXT-MS-WIN-GDI etc. dll files where missing.
I looked at a few posts implying that these are included in Visual C++ Redistributable packages, so I installed all editions of Microsoft Visual C++ Redistributable (both x86 and x64 just to be sure).
But I still have the problem. What am I missing here? Any help would be greatly appreciated.

MATLAB R2013a is not supported with CPLEX 12.7.1 (see the detailed system requirements). You'll either have to use a newer version of MATLAB or an older version of CPLEX.

Related

MATLAB codegen: /lib64/libstdc++.so.6: version: 'GLIBCXX_3.4_20' not found

Trying to run codegen with MATLAB 2019a on a linux box and got the error:
... /lib64/libstdc++.so.6: version: 'GLIBCXX_3.4_20' not found ...
I have /lib64/libstdc++.so.6, just (apparently) not the right version. How can I resolve this?
Here is a list of supported compilers for your version of MATLAB.
Apparently MATLAB R2019a on Linux requires GCC 6.3.x. Make sure you have that version installed.

Installing openCV on MATLAB with mex and MinGW64

I'm trying to install OpenCV on MATLAB2015b using mexopencv. I have downloaded and successfully installed MATLAB support for MinGW-w64 C/C++ Compiler add-on in MATLAB. This is MATLAB's suggested compiler when I type mex -setup. However, when I run mexopencv.make in MATLAB, I get the following error:
Error using mexopencv.make>pkg_config (line 333)
OpenCV library path not found: D:\opencv\build\x64\mingw\lib
Error in mexopencv.make>mex_options (line 265)
[cv_cflags, cv_libs] = pkg_config(opts);
Error in mexopencv.make (line 82)
mex_flags = mex_options(opts);
I have already added mexopencv-master directory to my MATLAB's Path. And I have already checked that I have downloaded the correct version of opencv for mexopencv (which is 3.4.1 as of now).
I don't know why \build\x64\mingw\lib\ doesn't exist. I have seen different tutorials but most of them use Microsoft Visual Studio 2013/2015 C++ to compile mexopencv. How can I compile OpenCV with MinGW-w64 on my own? Or is there another github package that I should've downloaded instead of this one?
I have tried to uninstall my current version of Visual Studio and install the 2013 version to use its C/C++ compiler. However, MATLAB doesn't recognize this compiler when I issue mex -setup.
Any help is appreciated. Also, I cannot use MATLAB's computer vision toolkit because I want to use a function that is not supported by it (Namely, the probabilistic Hough transform).

Undefined reference error when using mexcuda ubuntu

Ive installed matlab,gcc and CUDA toolkit on ubuntu .to use mexcuda .
but when i compile i get the following errors and i cant find any references on them anywhere .
Error using mex
/tmp/mex_42185702054896_15548/testmem04.o: In function `mexFunction':
tmpxft_00003e3a_00000000-5_testmem04.compute_70.cudafe1.cpp:(.text+0x152): undefined reference
to `__cudaPushCallConfiguration'
/tmp/mex_42185702054896_15548/testmem04.o: In function `__device_stub__Z9MulKernelPhPi(unsigned
char*, int*)':
tmpxft_00003e3a_00000000-5_testmem04.compute_70.cudafe1.cpp:(.text+0x35e): undefined reference
to `__cudaPopCallConfiguration'
collect2: error: ld returned 1 exit status
please note that when i first installed matlab, cuda 10 (my current version) was not supported by it , ive encountered the same thing when i installed matlab on windows , and fixed it by commenting a line in file "nvcc_g++.xml" and it works . when i did this in ubuntu matlab,matlab now detects the nvcc compiler but i get the previous error .
i realize "undefined reference errors " are linker errors , what should i do here ? i tried linking to cuda library but it didnt work .
For mexcuda, it is crucial that you match the CUDA toolkit to the version shipping with your installation of MATLAB (and Parallel Computing Toolbox). This is because Parallel Computing Toolbox ships a selection of libraries from the CUDA toolkit, and expects to be able to link against them. If you use the wrong version of the CUDA toolkit, all sorts of things can go wrong.
To check the appropriate version of the CUDA toolkit, look at the CUDA ToolkitVersion Version showing in the output from gpuDevice.
(Note that it is only the toolkit version that needs to match with MATLAB & PCT - it's almost always fine to get the latest driver).
For more details, see my answer https://uk.mathworks.com/matlabcentral/answers/432360-after-uninstalling-cuda-toolkit-still-matlab-responds-for-gpudevice over there on MATLAB Answers.

How the lower version MATLAB to use high edition visual studio C compiler [For example: Matlab 2012b use visual studio 2013 compiler ] [duplicate]

This question already has answers here:
matlab compiler installation problems
(2 answers)
Closed 7 years ago.
i try to use SPArse Modeling Software [ Version: 2.5,matlab interface ], it need to compiler first.so i run the compiler.m in MATLAB 2012b .but it goes wrong.
Here is the log
>> compile
Warning: Directory already exists.
> In compile at 144
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Error: Could not find the compiler "g++-4" on the DOS path.
Use mex -setup to configure your environment properly.
D:\PROGRA~2\MATLAB\R2012B\BIN\MEX.PL: Error: Unable to locate compiler.
Error using mex (line 206)
Unable to complete successfully.
Error in compile (line 440)
mex(args{:});
I guess the problem is the MATLAB 2012b mismatching the compiler in PC.
And I try to use visual studio 2013 as my the default C compiler for MATLAB 2012b.
when i using the mex -setup command.
only two choice as follow ,and do not see the visual studio 2013 compiler.
Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
I know MATLAB 2014b can use visual studio 2013 C compiler.
But how the lower version MATLAB to use high edition visual studio C compiler.
Someone else encountered this problem ?
My OS is windows 7 X64 , visual studio 2013 PRO, MATLAB 2012b.
I reference this ,but seems did't work.
Using Visual Studio 2013's C compiler for MATLAB
The compiler you are trying to use is not supported by your matlab version, you have to use one of the supported compilers.

which configuration option is used by Mex to compile using matlab?

say, if choose mexopts.sh as the configuration files for mex,
then how does mex decide which option listed in the mexopts.sh is used for compiling?
for example, using 32bit matlab on 64bit mac os x:
mexopts.sh looks like:
,,maci
........
,,maci64
......
Then, maci or maci64 is used when compiling?
What commands or way can I do in order to compile 32bit lib instead of 64bit lib?
Further explanation of my process and the error message I got :
I am using mac os x 10.8 (64bit) with matlab R2010a (32bit) to produce a binary mex-file.
The Xcode is 4.6 version, I installed Command Line Tools on my machine. Then I downloaded the patch from matlab for 2011 and 2012 version anyway. (if I don't install the patch, I got a lot of link errors saying some header files are missing).
After I installed the patch ( I believe it changes my mexopts.sh file), when I run mex a.cpp, I got error message saying that /Applications/MATLAB_R2010a.app/bin/maci64 cannot be found. Of course, it cannot find the maci64 folder, it is 32bit, there is only maci folder.
So Anyone knows what I should do in order to make matlab look for maci folder instead of maci64 folder? Thanks a lot!
MATLAB does not support cross compilation of MEX files. So your 32-bit MATLAB installation should be producing 32-bit MEX files even though the OS is 64-bit.
Also, from the article I've linked
Further, beginning with R2010b, a 32-bit version of MATLAB is no longer produced for the Mac.
If you're running R2010b or later, your MATLAB is not 32-bit anyway.
To see what switches the MEX script is invoking the compiler with, use the -v option.
You can also use the file tool to check whether the generated binary is 32 or 64-bit.
As its been explained, MATLAB produces MEX files of the same bit-ness as itself, not that of the OS. This is true at least on Windows with recent MATLAB versions, where you can have either 32-bit or 64-bit MATLAB running on 64-bit Windows. Other platforms are moving towards 64-bit versions only.
Here is another way to get the configured mex switches:
>> cc = mex.getCompilerConfigurations
>> cc.Details
In my case I get:
>> cc = mex.getCompilerConfigurations
cc =
CompilerConfiguration with properties:
Name: 'Microsoft Visual C++ 2010'
Manufacturer: 'Microsoft'
Language: 'C++'
Version: '10.0'
Location: 'C:\Program Files\Microsoft Visual Studio 10.0'
Details: [1x1 mex.CompilerConfigurationDetails]
LinkerName: 'Microsoft Visual C++ 2010'
LinkerVersion: '10.0'
>> cc.Details
ans =
CompilerConfigurationDetails with properties:
CompilerExecutable: 'cl'
CompilerFlags: [1x115 char]
OptimizationFlags: '/O2 /Oy- /DNDEBUG'
DebugFlags: '/Z7'
LinkerExecutable: 'link'
LinkerFlags: [1x327 char]
LinkerOptimizationFlags: ''
LinkerDebugFlags: '/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"'
To answer my own question, just for those who may be interested in it,
I checked the contents of mexopts.sh and modified the part for maci (specifically set ARCH=i386) , then compile. The error message is gone.