Why do I receive a linking error about mclInitial​izeApplica​tion_proxy and mclmcrInitialize_proxy when I compile my driver application that calls a C++ shared library compiled using MATLAB Compiler 4.10 (R2009a)?

10 views (last 30 days)
I have written a MATLAB function called mytest.m that is defined as follows:
function result = mytest(V)
result = sum(sum(V));
end
I am compiling this into a DLL using the MCC command using MATLAB Compiler 4.10 (R2009a) as follows:
mcc -W cpplib:Test -T link:lib mytest.m -v
Then I write a driver application called mydriver.cpp (see below), which when compiled with the following command
mbuild mydriver.cpp Test.lib
gives me the error: ERROR: mydriver.cpp(7) : error C3861: 'mclInitializeApplication_proxy': identifier not found mydriver.cpp(51) : error C3861: 'mclmcrInitialize_proxy': identifier not found C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Compile of 'mydriver.cpp' failed.
However, when I compile the same application using MATLAB Compiler 4.7 (R2007b), the compilation completes successfully.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Nov 2016
This error may occur only with MATLAB Compiler 4.8 (R2008a) or later versions because of changes that have been introduced in mclmcrrt.h and mclmcr.h, which impose the requirement that mclmcr.h always be included after mclmcrrt.h for the pre-processing stage.
In the attached driver application, the following code is found on Lines 1-2:
#include "mclcppclass.h"
#include "Test.h"
Here, mclcppclass.h (found in the <matlabroot>/extern/include directory) in turn includes mclmcr.h.
Also, in the generated Test.h file, the following code can be found:
#include "mclmcrrt.h"
#include "mclcppclass.h"
This results in mclcppclass.h being included before mclmcrrt.h, thus causing a symbol resolution issue for the identifiers mclInitializeApplication_proxy and mclmcrInitialize_proxy.
In order to resolve this issue, change the order of the header files in mydriver.cpp to the following:
#include "Test.h"
#include "mclcppclass.h"
Also, since Test.h already includes mclcppclass.h, you can entirely avoid including this header file in your driver application.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!