Mex function Implementation for nested-functions

7 vues (au cours des 30 derniers jours)
sree
sree le 23 Nov 2023
Commenté : sree le 29 Nov 2023
Hello,
We are trying to implement mex function for a nested function code.
We have a main function , addition()
We have another function - multiplication() which is getting called from addition function.
Also, we have another function division() which is getting called from multiplication function.
We have mexFunction written inside addition.c and getting the below error after executing the matlab file.
Error using mex
/usr/bin/ld: /tmp/mex_3689884132576332_19/addition.o: in function `addition':
addition.c:(.text+0x49): undefined reference to `multiplication'
We are attaching the screenshot for your reference.
We have declared multiplication and division functions inside commonheader.h file.
We have function definitions for multiplication and division functions in operation.c.
Please let us know if we are missing anything in implementing this mex -nested function.
Thank you
Sreelakshmi

Réponse acceptée

Bruno Luong
Bruno Luong le 23 Nov 2023
you did not include operation.c in mex command
  3 commentaires
sree
sree le 29 Nov 2023
Modifié(e) : sree le 29 Nov 2023
Thank you for sharing this idea with me.
By adding operation.c, during the mex build, we are able to resolve undefined reference error related to function.
But still there are a few dependency issues(like "unknown type name" errors for some structures defined inside files of different libraries ) within the functions called.
I'm currently trying to include those libraries to mex function to resolve that.
Thank you
Sreelakshmi
sree
sree le 29 Nov 2023
Yes, I did in the same way.It resolved the issue.
Thank you
Sreelakshmi

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by