Is it possible to debug mex code with Eclipse?

后端 未结 3 511
猫巷女王i
猫巷女王i 2020-12-29 08:00

I am trying to write some mex code but it is painful to debug it on the console with gbd. Is it possible to use Eclipse or the GUI of Matlab? If these are not feasible metho

3条回答
  •  轮回少年
    2020-12-29 08:32

    Here is my solution which works in Ubuntu 12.04, Matlab R2012b, and Eclipse IDE for C/C++ Developers Kepler Release.

    1. In Eclipse open "Debug Configurations" from the run tab. Then make a new "C/C++ Application".
    2. In the "Main"-tab write the correct path to the matlab executable in the "C/C++ Application" (mine is "/usr/local/MATLAB/R2012b/bin/glnxa64/MATLAB" NOTE: not MATLABPATH/bin/matlab). Main tab
    3. In the "Arguments"-tab add "-nojvm" as program arguments. Arguments
    4. In the "Environment"-tab add variable "MATLAB_DEBUG" with value "gdb" Environment
    5. Press "Apply" and "Debug"
    6. A "Matlab console" will open in the "Console" view.
    7. Write "dbmex on" in this console. This enables debugging.
    8. Run the mex file! (Matlab will stop at loading of each new mex file)
    9. Have fun debugging! :-)

提交回复
热议问题