Why my code doesn't execute correctly in other computers while works correctly in my computer?

I have a MATLAB code which I turned into an executable file. This code runs correctly in my computer but as soon as I put it in my Laptop for office use or bring it to other computer systems of my office or colleagues' systems, it provides me with the same error that shows error in 3 different lines, which is also shown at figure. However, my code is correct as it runs on my home computer and all my variables are well defined.
Kindly guide me with this issue. I am using MATLAB R2018a for all systems.
Thank you

3 Comments

As the error says coesamethod is not defined. Should this be a function or a variable?
If it is a function, maybe its not on the searchpath? You can check this with:
exist(coesamethod)
Thank you for your kind reply sir but the problem is that the program, the .exe file, runs finely in my PC. As soon as I copy it to another system, the size of the program automatically reduces by a few 100 bytes and stops working. If the funcion i.e. 'coesamethod' wasn't defined, it would have been a problem in my PC as well.
Perhaps the code is using run() with a hard-coded path.

Sign in to comment.

Answers (2)

The error message means, that the function coesamethod.m was not included during the creation of the executable. Try to include it explicitly.

1 Comment

Actually, I have tested the executable file on my PC. This file runs on my PC without having a need of MATLAB, however the issue arises when I try to run this file on my laptop, which has the same compiler R2018a.

Sign in to comment.

If it runs in MATLAB then it must be on the path. Did you change the path in the code? If so that would mean it could be found when you ran it in MATLAB but was not included when you compiled it.
mcc -m hyper_mass_size_model_fcn.m
If it was on the path, that would have found all required functions.
If you want, you can attach the code and I can try to compile it and run it.
Try calling the attached function in your startup code and see what functions it lists in the console window.

8 Comments

Thank you so much sir for explaining. Acutally, the problem was not with the path. Though, it is solved now.
Thank you again.
@Muhammad Osama, can you tell us what the problem actually was?
I may need to add that situation to the FAQ where it could help others in the future.
Sure sir,
The problem was with the conflicting compilers between my PC and my laptop, though both had the same version of MATLAB (R2018a). That made the .exe file to function on the original system, however presented the forementioned errors during file execution in my laptop. To be honest, I don't know what made the two compilers conflicting.
The solution that I found was:
If such type of errors arise, compile the original MATLAB program in the PC where the problem is being presented.
For more questions, please ask.
Thank you
Well that sounds really bizarre. Whether or not you even have a compiler on your target computer where you deployed your compiled program should have no effect at all. As far as I know when you run your app it runs your app and then determines what MCR library it needs, and then loads that. And that's all. It does not look to see if the target computer even has a compiler, and even if it did, it should not care if it was different than the development computer where it was actually compiled.
Exactly. It made me confused too and therefore I might have not made myself clear while asking the question. Because it is exe file and it should just function with the MCR file and never occured before. The solution I just posted was the only way that helped me overcoming this hurdle.
By the way, thank you for your time and response, sir.
But what would you do if the target computer did not have a full version of MATLAB with the compiler toolbox? There would be no way to compile the app on that computer. But you should still be able to deploy the app to that target computer. Would the problem not occur at all? Does it only occur if you try to deploy it to a computer that also has a compiler on it?
The problem still occurs and I have to recompile it. That solution that I provided is not good. I have no idea what to do because the problem continues...
That code works in my PC but not in any other. I hope somebody has solved it before or can suggest a better solution.
You can contact the Mathworks and they will solve it for you. The Compiler toolbox is very expensive so I assume you have a maintenance contract or you've bought it within the past year. They will figure it out. Or you can zip the executable and any run time files needed and I can try to install it here.

Sign in to comment.

Products

Asked:

on 10 Nov 2021

Commented:

on 15 Nov 2021

Community Treasure Hunt

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

Start Hunting!