matlab C api 사용시 mclmcrInitialize_proxy 에러가 발생할 때.

  • Post author:
  • Post category:Uncategorized
  • Post comments:0 Comments

Technical Solutions

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

Date Last Modified: Thursday, July 30, 2009

Solution ID:   1-AB2V2G
Product:   MATLAB
Compiler
Reported in Release:   R2009a
Platform:   All Platforms
Operating System:   All OS

 

Subject:

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

Problem Description:

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:

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.

Solution:

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.

Dr.kchris

Hello, I'm Dr.kchris, a neuroscience researcher. I love studying and trying new things and also love challenging myself. Have a great day! :)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.