I tried running a simple Pthread program. It compiled fine but gave a runtime error. I don't know how to fix it. It says error in line 4 . However, line 4 sounds fine to me. Can someone help me?
#nclude<pthread.h>
#include<stdio.h>
void *thread_routine(void* arg)
{
printf("Inside newly created thread \n");
}
Did you try to run it? The errors I mentioned above occur during runtime. When I compile this program using "cc -lpthread programName.c " (I am using linux) , it compiles fine. but when I try to run it, then it gives errors.
Those don''t look like run time errors. It looks to me like you might be trying to run the source code. After compiling there should be a binary file that you should run instead. You can specify the name of that file in your compile command:
Yes, it works now. You are right, I was trying to run the source code. Thanks a lot for your help. I really appreciate this forum as a great tool to learning. Thanks again.