Undefined symbols for architecture x86_64 error. Mex S-Function
2 次查看(过去 30 天)
显示 更早的评论
Okay, so I am far from an experienced coder, and am helping my professor with a project. I received a collection of MATLAB functions that are represented in Simulink. I had to create new mex files, which I thought worked at first, but when I would run it through Simulink, I was coming up with an "invalid sizes vector" error (block error). The original code is in c, and I'm using Visual Studios as my compiler. The c-code is an S-function within Simulink as well. After researching a bit, I found that I had to add
#ifdef MATLAB_MEX_FILE
#include "simulink.c"
#else
#include "cg_sfun.h"
#endif
to the end of all mex S-functions. Once I did this, I tried re-creating the mex files and got this error:
>> mex Core_Neutronics.c
Undefined symbols for architecture x86_64:
"_dgesvd_", referenced from:
_mdlOutputs in Core_Neutronics.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "Core_Neutronics.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.
------------------------------------------------ ------------------------------------------------
My code consists of two lines where dgesv is used.
/* DGESV prototype */
extern void dgesv_( int* n, int* nrhs, double* a, int* lda, int* ipiv, double* b, int* ldb, int* info);
Then later,
dgesv(&matrix_size, &brnhs, a, &matrix_size, ipvt, b, &matrix_size, &info);
I notice that there is an underscore in the first line, but not later on in the second. Even when this is changed, the same error still occurs. Does anyone know what's going on? I know that I don't have a bunch of detail for my code, but I was hoping someone could point me in the right direction. Also, I do have these libraries called out in Matlab
/* C Header for the Simulink interface */
#include "simstruc.h"
/* Other C Headers */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <math.h>
Could it be that I don't have these libraries installed somehow? (If not, how do I install these?)
0 个评论
回答(1 个)
Muruganandham Subramanian
2014-2-20
Try using
dgesv(matrix_size, brnhs, a, matrix_size, ipvt, b, matrix_size, info);
Because, when you are passing as an pointer variable, it processes the address
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!