Hey everyone,
I'm using Dev-C++ to compile the following program. It's simple but for some reason its not working.
#include <stdio.h>
#include <unistd.h>
int main()
{
int n, fd[2], pid;
const int MAXLINE = 4096;
char line[MAXLINE];
if(pipe(fd) < 0) {
printf("Pipe error");
}
if((pid = port()) < 0) {
printf("Fork error");
}
else if(pid > 0){
close(fd[0]);
write(fd[1], "Hello world\n", 12);
}
else {
close(fd[1]);
n = read(fd[0], line, MAXLINE);
write(STDOUT_FILENO, line, n);
}
system("PAUSE");
return 0;
}
This is my compile log,
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Dev-Cpp\Projects\Test\main.c" -o "C:\Dev-Cpp\Projects\Test\main.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
{My directory}\Temp/ccEVcaaa.o(.text+0x65):main.c: undefined reference to `pipe'
{My directory}\Temp/ccEVcaaa.o(.text+0x7a):main.c: undefined reference to `port'
collect2: ld returned 1 exit status
Execution terminated
Could someone help me out and let me know what I am doing wrong? Do I have to run it with some sort of cmd line param's?
Thanks in advance for the help.
-Barefoot