Undefined link to fork () in the Code :: Blocks editor on Windows

When I run the code below in Code :: Blocks on Windows. I used fork () to get an error called undefined. I installed / selected the GCC compiler as my default compiler.

#include<stdio.h>       
#include<unistd.h>          
void main()          
{       
 int x;       
 x = 0;       
 fork();       
 x = 1;        
 ...     
 ....    
}

Please help me and tell me, can I use unix / linux programs in Code :: Blocks in Windows environment correctly?

And I'm writing another program,

main()
{
int x = 0;
if(x == 0)
{
printf("X = %d", x);
sleep(1000);//used delay also
x = 1;
printf("Now X = %d", x);;
}

Here it gives eroor that the undefined reference to sleep () and / * delay is also * /.
Please help me.

+5
source share
5 answers

, Unix Windows, , , IDE . cygwin, .

2017: Windows Linux.

+6

fork Windows.

+2

fork() unix, undefined, Windows. Windows fork().

0

cygwin , spawn() ms-dos. .

0
source

There is no fork () system call on Windows, you can try cygwin or pthreads instead.

0
source

All Articles