Why do I receive an error when compiling a MATLAB graphics application?

1 view (last 30 days)
I am having a problem compiling a stand-alone program that I wrote in MATLAB. The Engine of this file is a MATLAB function that calls a bunch of other files. I used the following MATLAB compiling command to create a stand-alone executable:
mcc -t -B sgl filenames.m
I believe I have the C Math Library, C Graphics Library, and other MATLAB libraries installed. However, I keep receiving the following error message:
ERROR: undefined reference to '_mclMainhg'

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Apr 2023
Edited: MathWorks Support Team on 19 Apr 2023
This error occurs when the MATLAB C/C++ Graphics library is not properly installed.
You can verify if this is indeed the case by looking into the
$MATLAB/extern/examples folder
(where $MATLAB = the MATLAB root directory on your machine)
to see if a folder called "sgl" exists. If it does not exist, you do not have the MATLAB C/C++ Graphics Library and therefore will not be able to compile any MATLAB application that uses graphics.
You may purchase and install the MATLAB C/C++ Graphics Library product if you are using MATLAB 6.1 (R12.1) and earlier.
In MATLAB 6.5 (R13), the MATLAB Compiler tool is sold as an integrated product that includes the MATLAB C/C++ Graphics Library and the MATLAB C/C++ Math Library. Therefore, if you do not see the "sgl" folder in MATLAB 6.5 (R13), you will need to purchase and install the complete MATLAB Compiler product.
If you need more information about our product lines and specific information about any of our products you can visit
.
You may also send an email to our Pricing and Purchasing team at pricing@mathworks.com for more information about purchasing this product.

More Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!