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)?

14 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品


版本

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by