C++ shared library compiling/packaging errors

조회 수: 7 (최근 30일)
Didier
Didier 2015년 1월 19일
댓글: Didier 2015년 1월 20일
I’m working on a MacBook Pro (OS X Yosemite Version 10.10.1) with Matlab R2014b and Xcode 6.1.1. I’m trying to build a C++ shared library using the Library Compiler App graphical tool. I’ve followed the recommandations of the documentation and was successful in building and using the shared library for the addmatrix.m example. When I go through the same steps for my project with multiple .m files organized around a main.m file, the process of creating the binary files and the different directories seems to be completing fine. Unfortunately, there are some issues reported in the PackagingLog.txt file that prevent me to later integrate correctly the shared library into a testing application. The compiling command seems to complain about the types of the created main.cpp file arguments and returning variable in relation to the main.h include file.
For instance: main.h:114:25: error: 'main' must return 'int' extern LIB_main_CPP_API void MW_CALL_CONV main(int nargout, mwArray& flagg, const mwArray& dum); ^~~~ int main.cpp:122:1: error: 'main' must return 'int' void MW_CALL_CONV main(int nargout, mwArray& flagg, const mwArray& dum) ^~~~ int
main.h:114:43: error: second parameter of 'main' (environment) must be of type 'char '
main.cpp:122:19: error: second parameter of 'main' (argument array) must be of type 'char ' void MW_CALL_CONV main(int nargout, mwArray& flagg, const mwArray& dum)
Any idea? I haven’t included all the files but I can do it if needs be. Thank you for your help.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 1월 20일
Hi,
I'm not sure, but I could imagine it's the name "main". In C/C++ the main function has a special meaning (and a special signature). Try to rename your main.m to mainfcn.m or what ever and let us know if the problem still exists.
Titus
  댓글 수: 1
Didier
Didier 2015년 1월 20일
Your answer completely solved the problem. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by