0

I was trying to compile a .c file in Matlab 2014a on a Windows 7(64-bit) machine. The compiler was a Mingw-w64 gcc:

mex -lsundials_nvecserial -lsundials_cvode -lm -IC:/sundials/include -LC:/sundials/lib model_pike_cvode.c

Then it gave me some error:

Error using mex
gcc: error: sundials_nvecserial.lib: No such file or directory
gcc: error: sundials_cvode.lib: No such file or directory
gcc: error: libm.lib: No such file or directory

First of all, I am pretty sure that "sundials_nvecserial.lib" and "sundials_cvode.lib" are under the "C:/sundials/lib/" folder, which is indicated in the command after the -L option.

Second, I am aware that I don't have a libm.lib in my machine. I need the option because the .c file '#include '. I have a Visual Studio installed though I was not using it. I can find 'math.h' but not 'libm.lib' in it. So I guess the question is, how to tweak/avoid the '-lm' option on a Windows machine.

Thank you in advance,

John

  • How are compiling with gcc on Windows? Are you using gnumex? If so, try `mex model_pike_cvode.c COMPFLAGS="$COMPFLAGS -IC:/sundials/include -LC:/sundials/lib" GM_ADD_LIBS="$GM_ADD_LIBS -lsundials_nvecserial -lsundials_cvode -lm"`. Matlab has changed their MEX interface in recent versions of Matlab so this might not work, but this is how I would pass flags and libraries with gnumex on Windows when compiling on older versions of Matlab. – JustinBlaber Aug 30 '15 at 17:25
  • Thank you for your reply. I used MinGW-w64. I tried your command but it gave me a new set of errors. Based on the prompt, it seems that the sundials library is not correctly linked. – John Zhang Aug 31 '15 at 02:52

0 Answers0