Load Library error Matlab - matlab

I intend to work with OpenCV 1.1 version and Matlab2011 together. The program uses call to load library. However, it returns an error
> In loadlibrary at 347
In Untitled at 4
Error using loadlibrary (line 421)
There was an error loading the library "C:\Program Files
(x86)\OpenCV1.1\bin\cxcore110.dll"
C:\Program Files (x86)\OpenCV1.1\bin\cxcore110.dll is not a valid
Win32 application.
I have tested the program in Matlab 2008 and 2010 where it gives error of a different kind I have installed x64 Compilers and Tools and my system has Visual Studio2008 and 2010 with SDK7 and 6.1. Also, on doing MEX setup I get the following options
Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[2] Microsoft Visual C++ 2010 Express in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler: 2
This also returns the error
Error in ==> untitled at 5
loadlibrary(...
I am perplexed at what to do as this problem is persistently appearing. I even followed the thread in link where tit mentions that 2011 supports load library. So,why does it not work?Please help.

Applications compiled for 32bits don't mix with applications compiled for 64bits. If your OpenCV was compiled for 32bits, make sure Matlab is 32bits as well as your compilers.
BTW, seriously consider moving to a more recent version. OpenCV 1.1 is jurassic!

Related

mex file matlab. Libsvm error

I tried compiling .c files to .mex , everything goes well and mex files are created but still it gives me the following errors. can anybody explain what is .exp file and why its giving me error?
Could Not Find E:\research data\libsvm-3.21\libsvm-3.21\matlab\svmtrain.exp
Could Not Find E:\research data\libsvm-3.21\libsvm-3.21\matlab\svmtrain.exp
MEX completed successfully.
Building with 'Microsoft Windows SDK 7.1 (C++)'.
Could Not Find E:\research data\libsvm-3.21\libsvm-3.21\matlab\svmpredict.exp
Could Not Find E:\research data\libsvm-3.21\libsvm-3.21\matlab\svmpredict.exp
MEX completed successfully.
This problem may be caused by the different version of the C++ compiler.
I solved this problem by chooseing the C++ 2010 compiler.
To setup the compiler, type "mex -setup" first then type "mex -setup:I:\matlab2014b_win7\installation(root of your matlab installation)\bin\win64\mexopts\msvc2010.xml"
MEX configured to use 'Microsoft Visual C++ 2012 (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different C compiler, select one from the following:
Microsoft Visual C++ 2010 (C)
mex -setup:I:\matlab2014b_win7\installation\bin\win64\mexopts\msvc2010.xml C
Microsoft Visual C++ 2012 (C)
mex -setup:C:\Users\Administrator\AppData\Roaming\MathWorks\MATLAB\R2014b\mex_C_win64.xml C
Microsoft Visual C++ 2013 Professional (C)
mex -setup:I:\matlab2014b_win7\installation\bin\win64\mexopts\msvc2013.xml C

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.

Matlab r2013a doesn't recognize any compiler in order to protect a model

I have a problem with my r2013a Matlab.
I want to protect a model using Simulink.ModelReference.protect('test') command. For this
I have to configure my compiler. I'm using the mex -setup command, and the xpcsetCC -setup command.
At first, Matlab says that is all ok with the compiler, but when i try to execute the Simulink.ModelReference.protect('model') command it shows an erro saying that there is no compiler avaiable.
Here are the sequences of commands:
PART 1 - 'mex -setup'
INPUT
mex -setup
OUTPUT
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n?
INPUT
y
OUTPUT
Select a compiler:
[1] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) in C:\Program Files (x86)\Intel\ComposerXE-2011\
[2] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) in C:\Program Files (x86)\Intel\ComposerXE-2011
[3] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[4] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler:
INPUT
4
OUTPUT
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n?
INPUT
y
OUTPUT
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
Trying to update options file: C:\Users\Guilherme\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\msvc100opts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
PART 2 - 'xpcsetCC -setup'
INPUT
xpcsetCC -setup
OUTPUT
Select your compiler for xPC Target.
[1] Microsoft Visual C++ Compilers 2010 Professional in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler:
INPUT
1
OUTPUT
Verify your selection:
Compiler: Microsoft Visual C++ Compilers 2010 Professional
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n?Y
Done...
Until now everthing is ok, but next there is an error:
Part 3 - Simulink.ModelReference.protect('test')
INPUT
Simulink.ModelReference.protect('test')
OUTPUT
### Model reference SIM target (test_msp.mexw64) for model test is out of date because test_msp.mexw64 does not exist.
### Updating model reference SIM target for model: test
Warning: The model 'test' does not have continuous states, hence Simulink is using the solver 'VariableStepDiscrete' instead of solver 'ode45'.
You can disable this diagnostic by explicitly specifying a discrete solver in the solver tab of the Configuration Parameters dialog, or by
setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics tab of the Configuration Parameters dialog
Warning: Using a default value of 0.2 for maximum step size. The simulation step size will be equal to or less than this value. You can disable
this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters
dialog
### Build procedure for model: 'test' aborted due to an error.
Error using Creator.protect (line 287)
An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please
install one of the supported compilers for this release as listed at:
http://www.mathworks.com/support/compilers/R2013a/win64.html
MATLAB must be restarted after the compiler is installed.
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+Simulink\+ModelReference\protect.p>protect (line 74)
[harnessHandle, neededVars] = protectedModelCreator.protect(varargin{:});
I've already tried all different choices of available compilers. I also tried to choose no for the fist question of mex -setup ("Would you like mex to locate installed compilers [y]/n?") and choose the compiler manually. None of this worked.

mex in matlab r2011 - out of memory error

I am trying to use MEX. I use MATLAB R2011a and my compiler is
Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
I use this simple file:
http://www.shawnlankton.com/2008/03/getting-started-with-mex-a-short-tutorial/
and helloworld.cpp works, but demo.cpp does not. I either get a "out of memory" error, or MATLAB just crashes...
Appreciate any assistance.

problems with creating an exe file in matlab

this is the session of building exe file in matlab 7.1.
I think I have a problem with the compiler.
mbuild -setup
Please choose your compiler for building standalone MATLAB
applications: Would you like mbuild to locate installed compilers
[y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2008 Express in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
*****************************************************************************
Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit binaries,
Microsoft Visual C++ 2008 Express Edition requires that these two
packages be properly installed.
*****************************************************************************
Trying to update options file: C:\Users\****\AppData\Roaming\MathWorks\MATLAB\R2010a\compopts.bat
From template: C:\PROGRA~1\MATLAB\R2010a\bin\win64\mbuildopts\msvc90freecompp.bat
Done . . .
>> mcc -m mainmain.m -o mainmain
Could not find the compiler "cl" on the DOS path.
Use mbuild -setup to configure your environment properly.
C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Unable to locate compiler.
Error: An error occurred while shelling out to mbuild (error code = 2).
Unable to build executable (specify the -v option for more information).
??? Error using ==> mcc
Error executing mcc, return status = 1 (0x1).
if the problem is with the compiler, how can I install another compiler?
I have windows 7 (64 bits) and I want that the exe file will work on windows operating system.
This is probably the result of one of two issues.
1) You don't have the Windows SDK installed (as indicated in the error message). According to this MathWorks page regarding supported compilers
Both Microsoft Visual Studio 2008 and Windows Software Development Kit (SDK) 6.1 must be installed. When installing Microsoft Visual Studio, you must choose "X64 Compilers and Tools" when installing Microsoft Visual Studio; this is not selected by default.
Now, keep in mind, this reference is for the most recent release of MATLAB, but I'm betting that this information is still relevant to your issue.
You can download the SDK here.
2) It's also possible that the compiler that you're using simply isn't supported for your release of MATLAB. See here for info on supported compilers for MATLAB 7.1.