Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

used this code to make pipe need help

Status
Not open for further replies.

Maulkin

Programmer
Apr 8, 2002
19
AU
this code is surrposed to create a pipe place two messages on it then read them off.

Code:
#include <unistd.h>
#include <stdio.h>

#define msgSize 8

char *lock = &quot;1&quot;;
char *unlock = &quot;2&quot;;

main(){
	char inbuf[msgSize];
	int p[2], j;
	
	/* open the pipe */
	if (pipe(p) == -1){
		perror(&quot;pipe call&quot;);
		exit(1);
	}
	
	/* write the messages */
	write(p[1], lock, msgSize);
	write(p[1], unlock, msgSize);
	
	for(j = 0; j < 3; j++){
		read(p[0], inbuf, msgSize);
		printf(&quot;%s\n&quot;, inbuf);
	}
	
	exit(0);
}
[\code]

I get an error message when I try to build the message says

Linker Error (Severity 4)
	Module &quot;a&quot; in file &quot;app.obj&quot;
	references unresolved external &quot;_pipe&quot;
	at offset 000DH in segment &quot;_text&quot;.

Linker Error (Severity 4)
	Module &quot;a&quot; in file &quot;app.obj&quot;
	references unresolved external &quot;_perror&quot;
	at offset 0045H in segment &quot;_text&quot;.

can anyone help?
 
hey!
Just include the library path where the pipe call stays while compiling the code.
and let me know whether it works or not?
 
I was under the impression that the pipe call was in the unistd header. if it's not can you tell me where it would be
 
Yes, it's in <unistd.h>, assuming you're using Unix. I'm just pointing that out because I notice the errors refer to an &quot;app.obj&quot;, which sounds like you might not be using Unix (where it would normally be &quot;app.o&quot;). If you are, sorry, my mistake.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top