.m file (included into .exe) to string

Suppose I have a main function, which I will compile using mcc, and suppose I have a helper function, which I will include into the compilation, using the '-a' argument.
I want to extract the helper function's code as a string, from the main function exe. The helper function must be included in - no extracting from a separate .m file.
Pre-compilation, I was able to extract the code using importdata(), or fileread(), but after compilation it doesn't work properly.
I tried a few other methods, but nothing worked for me. Any suggestions? Thanks!

5 comentarios

jgg
jgg el 7 de En. de 2016
I'm not an expert on mcc, but I don't think that's possible. You can certainly read in the uncompiled .m file, but post-compilation, that shouldn't be possible.
You could try a work-around:
  • Save the file as a .txt file instead of a .m file
  • -a in the .txt file
  • Read in the data from the text file instead
You'll have an extra document floating around but it will be compiled into your compiled code so probably not an issue?
Harsheel
Harsheel el 7 de En. de 2016
All .m files are encrypted when they are being executed in the deployed environment. However, why do you want to read the code of a .m file from another .m file? Seems like we can better design this.
Yuval Weissler
Yuval Weissler el 10 de En. de 2016
jgg, thanks for the idea, I went with it, and it worked out.
Harsheel, it's a bit complicated, but I had a good reason for doing this =]
jgg
jgg el 10 de En. de 2016
I'm going to post this as a solution, so you can accept it and people can see how you solved the problem.
Harsheel
Harsheel el 10 de En. de 2016
sounds good Yuval :)

Iniciar sesión para comentar.

Respuestas (1)

jgg
jgg el 10 de En. de 2016

0 votos

This ended up being the solution, although it was posted as a comment: I'm not an expert on mcc, but I don't think that's possible. You can certainly read in the uncompiled .m file, but post-compilation, that shouldn't be possible.
You could try a work-around:
  • Save the file as a .txt file instead of a .m file
  • -a in the .txt file
  • Read in the data from the text file instead
You'll have an extra document floating around but it will be compiled into your compiled code so probably not an issue?

Categorías

Más información sobre C Shared Library Integration en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de En. de 2016

Comentada:

el 10 de En. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by