Why is the c/c++ code generated by MATLAB Coder not standalone, that is, depends on other library?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I write a MATLAB function using some functions from Image Processing Toolbox as follow
function Y = TestImageAffine(X, T) %#codegen
H = fspecial('gaussian', 7, 0.5);
X = imfilter(X, H, 'cir', 'same', 'conv');
tform = affine2d(T);
outputView = imref2d(size(X));
Y = imwarp(X, tform, 'OutputView', outputView);
The 4 c/c++ code files are gernerated successfully by MATLAB Coder as following
TestImageAffine.h
TestImageAffine.c
TestImageAffine_types.h
rtwtypes.h
In the c/c++ source file "TestImageAffine.c", 4 header files are included as follow
#include "libmwimfilter.h"
#include "libmwippfilter.h"
#include "libmwippgeotrans.h"
#include "tmwtypes.h"
For the MATLAB function "Y = TestImageAffine(X, T)" above, MATLAB Coder does NOT gernerate the 4 header files above.
So My question is that why does MATLAB Coder not gernerate the 4 header files above.
It is well-known that MATLAB Coder can gernerate "STANDALONE" c/c++ code. Why does the C source file above depend on the other header files?
Afterwards, I find that the 4 head files exist in the installation path "extern" of MATLAB, and the-same-name files are found as following
libmwimfilter.lib
libmwimfilter.dll
libmwippfilter.lib
libmwippfilter.dll
libmwippgeotrans.lib
libmwippgeotrans.dll
So I think that the generated c/c++ code depends on additional library.
Finally, I add all the header files, library files and dll files into a Microsoft Visual c++ 2010 project, but the build process fails as follow
" unresolved external symbol _ippgeotransCaller referenced in function _ippgeotrans"
I find out the function "ippgeotransCaller" which is declared in the header file "libmwippgeotrans.h", but I do not know the relationship between ippgeotransCaller and _ippgeotransCaller which appears above
I do not know what's wrong with my work?
4 comentarios
Steven Lord
el 27 de Abr. de 2017
I believe this is discussed in the license agreement. If after reading through the license agreement (in the Resources section on the Home tab of the Toolstrip, click the triangle below the Help button and select Terms of Use) you still have questions, please contact MathWorks Customer Service using the Contact Us link in the upper-right corner.
Ryan Livingston
el 1 de Mayo de 2017
gives more information about this. Specifically, bullet 3 describes a means of disabling the use of the libraries, when possible. Namely, choose hardware other than MATLAB Host Computer like:
cfg = coder.config('lib');
cfg.HardwareImplementation.ProdHWDeviceType = 'Intel->x86-64 (Linux 64)'
Note that some functions require the use of precompiled libraries so changing that setting may cause code generation to fail.
Respuestas (2)
Ryan Livingston
el 28 de Mayo de 2014
As dpb said, some functions from the Image Processing Toolbox leverage libraries to provide both functionality and performance. If you search for imwarp here:
you will see that it says that a library is used.
To use the generated code directly in a Visual Studio project, the necessary libraries and include paths need to be added. When you generated code, you should have gotten a make file which will list out these dependencies so you can add them to your project.
Alternatively, you could build a static (LIB) or shared library (DLL) using MATLAB Coder. Then you could link against it in your Visual Studio project and include the generated header files. This lets MATLAB Coder do the work of calling the C compiler on the generated code so that the dependencies are set up properly to build it.
0 comentarios
Alex Zlotnik
el 23 de Mzo. de 2015
Check packNGo option to export the code after generation.
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!