C++ shared library compiling/packaging errors

8 Ansichten (letzte 30 Tage)
Didier
Didier am 19 Jan. 2015
Kommentiert: Didier am 20 Jan. 2015
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.

Akzeptierte Antwort

Titus Edelhofer
Titus Edelhofer am 20 Jan. 2015
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 Kommentar
Didier
Didier am 20 Jan. 2015
Your answer completely solved the problem. Thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by