Try to search your question here, if you can't find : Ask Any Question Now ?

make: *** No rule to make target 'main.c', needed by 'main.o'. Stop

HomeCategory: stackoverflowmake: *** No rule to make target 'main.c', needed by 'main.o'. Stop
Avatarjulie asked 4 weeks ago

I have 3 .c files in my src directory and i have a Makefile in the parent directory of src. All my c files just use standard header files.
The error i am getting while using make command is

make: *** No rule to make target ‘main.c’, needed by ‘main.o’. Stop.

I tried all the tweaks that people have mentioned here and there but could not solve the problem. help please.

i tried including vpath directive too.

Makefile

vpath src
vpath inc
CFLAGS=-I inc
output: main.o helloExec.o execDemo.o
    $(CC) -o $(CFLAGS) $<

main.o: main.c
    $(CC) -c $(CFLAGS) $< $(CFLAGS)
helloExec.o: helloExec.c
    $(CC) -c $(CFLAGS) $< $(CFLAGS)
execDemo.o: execDemo.c
    $(CC) -c $(CFLAGS) $< $(CFLAGS)
clean:
    rm -f *.o output

main.c

#include<stdio.h>

int main()
{
    printf("hellon");
    return 0;
}

execDemo.c

#include<stdlib.h>
#include<unistd.h>

int main()
{
    printf("execDemo with pid = %dn", getpid());
    return 0;
}

helloExec.c

#include<stdlib.h>
#include<unistd.h>

int main()
{
    printf("helloExec with pid = %dn", getpid());
    return 0;
}
1 Answers
Best Answer
AvatarArben answered 4 weeks ago
Your Answer

9 + 4 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com