Application Extension .dll from a .c File
古いコメントを表示
I have no MATLAB experience. I inherited a piece of Labview code that uses a Matlab complied .dll
Problem is the .dll had a memory leak that I was able to detect and remove.
Now I have no idea how to recompile the c File to produce the .dll file.
The c file has a comment that I believe relates to how the file must be compiled, see below
/* MATLAB Compiler: 4.3 (R14SP3)
* Arguments: "-B" "macro_default" "link:lib" "reverse_wrapper.m"
*/
The c File is in a folder that has a number of other files including ranging from .dll .m .exports and .m files
Searching the development PC, I see MATLAB Component Runtime version 7.3 is installed.
Please help me with a detailed step by step procedure to get compile my .c file into a .dll do I need to download a compiler and other tools?
13 件のコメント
Walter Roberson
2021 年 12 月 11 日
You will need MATLAB Compiler product.
If you were using a much newer release of MATLAB, you would also need MATLAB Compiler SDK.
Unfortunately, the version you are using is so old that a lot of practical knowledge of it has been lost -- it operated quite differently than modern versions. @Jan might happen to know how to use it though.
Bryne Chipembe
2021 年 12 月 11 日
Walter Roberson
2021 年 12 月 11 日
You can't buy the compiler for a release that old these days -- at least not directly. If you had the compiler for any newer version, the license would authorize you to use the compiler for the older release.
Once you get to roughly r2010a, the compiler would start complaining that your code will not work for 64 bit versions. There are command line options for backwards compatibility, but they will not get you past R2015b -- because R2015b is the last 32 bit version of MATLAB, and your code would definitely have to be touched up to be compatible with 64 bit MATLAB.
At the moment, I have no information about which version of LabView requires which version of MATLAB. You are using a 32 bit version of LabView at the moment, and that would not be able to call 64 bit .dll (operating system limitation.)
R2015a introduced MATLAB Compiler SDK as a product, and for your particular purpose (creating a DLL) you would need that product as well as MATLAB Compiler. Before R2015a, Mathworks offered some products with "Builder" in their name; unfortunately my memory is not currently filling in which of the "Builder" products would have been suitable.
Back in R14SP1, the compiler technology was completely different and the "Builder" products were not relevant.
Bryne Chipembe
2021 年 12 月 11 日
Walter Roberson
2021 年 12 月 11 日
If you have the appropriate software package installed, then you should just have to cd to the directory and execute
build_reverse_hex_dll
This will invoke mcc and mbuild to do the compiling.
Back in those days, mcc and mbuild were both parts of MATLAB Compiler; these days mcc is part of MATLAB Compiler and mbuild is part of MATLAB Compiler SDK.
If you do not have MATLAB Compiler installed, then you have a problem. The Component Runtime you see is definitely not able to compile anything.
Bryne Chipembe
2021 年 12 月 12 日
Walter Roberson
2021 年 12 月 12 日
The compiler directory contains the .m and .fig that you were compiling to make the GUI application. It does not have any trace of tools to do the compiling with
You do not use those Arguments.
What happened is that at some point the MATLAB Compiler was used to compile a .m file into a .c file. The Arguments list you see inside the .c file is a record of the command line arguments that were used to generate the .c from the .m
Inside the C code, I notice sections such as
typedef struct {
int32 dimSizes[2];
float64 Numeric[1];
} TD2;
Those sections are not compatible with 64 bit MATLAB, as dimensions are now uint64 . But I think the code might be okay with 32 bit MATLAB (up to R2015b)... though you might have to use some command line switches.
Was it a .c file or a .m file that you changed? If it was the .c file only, then we just might be able to compile for you... maybe... with some effort.
Unfortunately I do not have a Windows development system (licensing conflicts.)
Bryne Chipembe
2021 年 12 月 12 日
Walter Roberson
2021 年 12 月 12 日
I suspect that if you compile the .c to a .obj and link against the proper libraries that you could get the necessary .dll
Bryne Chipembe
2021 年 12 月 12 日
Walter Roberson
2021 年 12 月 12 日
編集済み: Walter Roberson
2021 年 12 月 12 日
These days, MATLAB Compiler is a marketting name for a product that takes .m files and generates a data structure that gets embedded into an .exe, along with a copy of the MATLAB computation engine (same one used to calculate for interactive MATLAB.)
Back in the release you were using, MATLAB Compiler was able to generate C code, that you then compiled with a handy external compiler. You already have that C code now. Back then you could have compiled with lcc-32 (a free compiler that was supplied with MATLAB with some products), or Visual C 6.0 Professional, or Visual C 7.1 Professional. You can get lcc-win32 from https://lcc-win32.services.net/
Bryne Chipembe
2021 年 12 月 12 日
編集済み: Bryne Chipembe
2021 年 12 月 13 日
Bryne Chipembe
2021 年 12 月 13 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!