DSPRelated.com
Forums

use mex to compile math lib function

Started by Bing Jian February 14, 2003

Hi, there,

Assume I have a mexmain.c which contains
mexFunction(), in mexFunction(), I call another
function e.g. test() defined in another c file
e.g. test.c.

The test.c is very simple

#include <math.h>

int test()
{

return sqrt(4);

}

If I generate test.obj by 'lcc test.c', (I use lcc-win32 as my
c compiler) then command
'mex mexmain.c test.obj' will give following err:
test.obj .text: undefined reference to '_sqrtid'

However if the test.obj is generated by 'mex -c test.c',
and then 'mex mexmain.c test.obj', it works.

I am confused about the difference between these 2 ways.
Anybody can explain it?

Thanks in advance! --
Bing