Generating a 64-bit compatible .c and .h file using newer MATLAB version
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I hope you are doing good.
I need help in one of the issue that I am stuck to. I am working with OPAL-RT Hypersim a real-time simulator software that allows to import simulink models. Back in 2017 my teachers at university developmed some Generator Excitor, Governor and Phasor Measurement circuit and then imported them back to Hypersim as at that time Hypersim did not had those blocks in its library. These .c and .h files were generated in MATLAB/SIMULINK 2015 version which was 32-bit. However, we recently had an upgrade of simulator and our new realtime simulator is 64 bit.
So now, as I am trying to run the model in Hypersim it gives me error of comapitibility. I am looking for a way to convert those .c and .h file using a 64-bit MATLAB (more recent version 2022/2023) version however, I am unaware how to do so.
Any help or assistance in this regard will be highly helpful to me.
Kind Regards,
Hamza
7 comentarios
Oliver Jaehrig
el 9 de Sept. de 2024
The best would be to get the m-files and Simulink models which were used to generate the code from.
If this is not possible, I believe you manually need to review the code and rewrite it.
Respuestas (1)
Kautuk Raj
el 11 de Sept. de 2024
Editada: Kautuk Raj
el 11 de Sept. de 2024
To resolve the compatibility issue between 32-bit and 64-bit generated code, you can follow the steps below to recompile your existing 32-bit .c and .h files using a 64-bit version of MATLAB. By carrying out this recompilation, the conversion between 32-bit code and 64-bit code can be carried out.
1. Set Up Your Environment:
- You already have a 64-bit version of MATLAB installed.
- Install a compatible C/C++ compiler that works with your MATLAB version. Follow this documentation page for guidance: https://www.mathworks.com/help/releases/R2022a/matlab/matlab_external/choose-c-or-c-compilers.html
2. Prepare Your Files:
- Locate the original.c and.h files generated from the 32-bit MATLAB environment.
- Ensure that any dependencies or additional files needed by these.c and .h files are available.
3. Compile the Files:
- Use the mex command (https://www.mathworks.com/help/releases/R2022a/matlab/ref/mex.html) to compile the.c files. For example: mex your_file.c
4. Check for Compatibility Issues:
- If there are any errors during compilation, they might be due to deprecated functions or compatibility issues between 32-bit and 64-bit environments. Review the error messages carefully and make necessary code adjustments.
- You may need to update certain parts of the code to comply with the 64-bit architecture, such as pointer arithmetic or data type sizes.
After successful compilation and testing, import the newly compiled files into Hypersim (the real-time simulator software being used) and verify that the model runs without compatibility errors.
By following these steps, you should be able to compile and convert your existing code to work with a 64-bit environment.
0 comentarios
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!