execl("/usr/bin/cc","cc","myprog.c",NULL)
I use the this line for compiler to myprog.c in myMainProg. But myprog.c have #include "math.h" . So I have to add -lm. How can I do that?
execl("/usr/bin/cc","cc","myprog.c",NULL)
I use the this line for compiler to myprog.c in myMainProg. But myprog.c have #include "math.h" . So I have to add -lm. How can I do that?
Command (from shell) to link your program should be:
cc myprog.c -o myprog -lm
So if you want to use execl
to compile it from another program you should use:
execl("/usr/bin/cc","cc","myprog.c", "-o", "myprog", "-lm", (char *) NULL);
Edit: I almost forgot when using execl()
the ending NULL
argument must be cast to char *