mex compilation error running fftw3 library
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
I need to compile a c++ code as a mex file. It uses the library fftw3. For now I am just trying to run a simple fftw3 example code dowanloaded from
https://github.com/undees/fftw-example/blob/master/fftw_example.c
If I run it from the terminal it compiles the code:
gcc -Iusr/local/include/ -L/usr/local/lib -lfftw3 -pat_to_fftw_example.c
But if i run the same in matlab:
mex -Iusr/local/include/ -L/usr/local/lib -lfftw3 -pat_to_fftw_example.c
I get this error:
Error using mex
ld: warning: directory not found for option '-L/usr/local/opt/llvm/4.0.0_1'
Undefined symbols for architecture x86_64:
"_mexFunction", referenced from: -exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anybody knows how to solve it?
Thanks
0 Commenti
Risposte (1)
Aylin
il 2 Giu 2017
The "Undefined symbols for architecture..._mexFunction" error is usually caused by a missing mexFunction function.
In C/C++ applications, the program entry point is usually defined using the main function which has a specific signature:
int main() {...}
int main( int argc, char *argv[] ) {...}
Similarly, the entry point in a MATLAB MEX file is defined using the mexFunction:
void mexFunction( int nlhs, mxArray *plhs[], int prhs, const mxArray *prhs[] ) {...}
https://www.mathworks.com/help/matlab/apiref/mexfunction.html
If you add a mexFunction to your 'fftw_example.c', it can be compiled with the mex command. See some of the mex examples for more information:
https://www.mathworks.com/help/matlab/matlab_external/standalone-example.html
0 Commenti
Vedere anche
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!