Matlab 2013b generated code produces Undefined symbols for architecture x86_64 error in mex

穿精又带淫゛_ 提交于 2019-11-29 15:47:08

The OP discovered that all source files need to be specified on the mex command.

This can cause compilation to succeed, but linking to fail, if all the necessary declarations are included by the main source file.

Here is some additional information from the Linking Multiple Files section of "Building MEX-Files" on the MathWorks website:

You can combine multiple source files, object files, and file libraries to build a binary MEX-file. To do this, list the additional files, with their file extensions, separated by spaces. The name of the MEX-file is the name of the first file in the list.

The following command combines multiple files of different types into a binary MEX-file called circle.ext, where ext is the extension corresponding to the current platform:

mex circle.c square.obj rectangle.c shapes.lib

As it says above, put the file with mexFunction as the first in the list so that the MEX-file gets the name from that file.

The mex help page has a section "Build MEX-File from Multiple Source Files" with a similar example, although with Fortran source:

mex -largeArrayDims fulltosparse.F loadsparse.F

The MEX-file name is fulltosparse because fulltosparse.F is the first file on the command line.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!