- https://www.mathworks.com/help/coder/ref/coder.codeconfig.html
- https://www.mathworks.com/help/coder/ref/coder.config.html
- https://www.mathworks.com/help/coder/ug/what-is-a-custom-toolchain.html
How should I use the specified compiler to compile and generate dynamic libraries when I use codegen in ubuntu
11 次查看(过去 30 天)
显示 更早的评论
I need to use another version of g++ to generate the required library files, which are placed in the /opt/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin path. What should I do to ensure that I can get the library files that can run on the aarch64 platform after executing the following code:
cfg = coder.config('lib');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('TargetLibrary', 'none');
inputType = coder.typeof(single(0), [1024, 2, 1]);
codegen -config cfg myNetPredict -args {inputType} -report
PS:Now I run CC = mex.getCompilerConfigurations and CC(1)output as follow:
Name: 'g++'
Manufacturer: 'GNU'
Language: 'C++'
Version: '5.4.0'
Location: '/usr/bin/g++'
ShortName: 'g++'
Priority: 'A'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: '/usr/bin/g++'
LinkerVersion: ''
MexOpt: '/home/test/.matlab/R2024a/mex_C++_glnxa64.xml'
0 个评论
采纳的回答
Adarsh
2025-5-2
I understand that you are trying to generate code in linux x86 aarch64 platform with a compiler other than the default compiler.
If you want to generate a “mex” file, you can follow the below documentation link to change the default compiler:
If you want to generate “libraries/C/C++” code rather than a “mex” file, then you can change the “Toolchain” attribute in the MATLAB Coder configuration parameters as the toolchain definition provides MATLAB Coder software with information about the software build tools, such as the compiler, linker, archiver.
MATLAB Coder software uses this information, along with a configuration object or project, to build the generated code. This approach can be used when generating static libraries, dynamic libraries, and executables.
MEX-file generation uses a different approach.
You can use the following command to list all the available toolchains:
coder.make.getToolchains
If you want to use a custom toolchain which is not available in the list then you can register the custom toolchain by following: https://www.mathworks.com/help/coder/custom-toolchain-registration.html
Here is an example code demonstrating on how to modify the Toolchain that is being used by MATLAB Coder:
cfg = coder.config('lib');
cfg.Toolchain = 'GCC Linaro AArch64 Toolchain';
For more information, you can refer to the following documentation links:
Hope it helps!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Build Configuration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!