pipe functions

support for the powerpc toolchain
Post Reply
joaopa
Posts: 2
Joined: Sat Aug 17, 2013 9:43 am

pipe functions

Post by joaopa » Sat Aug 17, 2013 9:59 am

Hello,

I am trying to port Pari/Gp (http://pari.math.u-bordeaux.fr/ ) to the Wii.
Pari/Gp uses widely the pipe functions (popen, pclose)
They are present in the stdio.h file. But the compilation
gives undefined reference to the function popen
undefined reference to the function pclose

the following test case shows the problem too
#include <stdio.h>

#define MAXSTRS 5

int main(void)
{
int cntr;
FILE *pipe_fp;
char *strings[MAXSTRS] = { "echo", "bravo", "alpha",
"charlie", "delta"};

/* Create one way pipe line with call to popen() */
if (( pipe_fp = popen("sort", "w")) == NULL)
{
perror("popen");
return 1;
}

/* Processing loop */
for(cntr=0; cntr<MAXSTRS; cntr++) {
fputs(strings[cntr], pipe_fp);
fputc('\n', pipe_fp);
}

/* Close the pipe */
pclose(pipe_fp);

return(0);
}

/opt/devkitPro/devkitPPC/bin/powerpc-eabi-gcc test.c
/tmp/cczYXw9b.o: In function `main':
test.c:(.text+0x6c): undefined reference to `popen'
test.c:(.text+0xf0): undefined reference to `pclose'
collect2: ld returned 1 exit status

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: pipe functions

Post by mtheall » Wed Aug 21, 2013 3:16 pm

This is probably popen creates a new process ('sort' in your case). I doubt there is process management from a homebrew perspective, let alone processes. In this specific case you may want to replace this code with an actual sort that doesn't rely on an external program. You said PARI/GP relies heavily on popen, so if it uses other programs like sed/awk/grep, you may be in over your head.

joaopa
Posts: 2
Joined: Sat Aug 17, 2013 9:43 am

Re: pipe functions

Post by joaopa » Tue Aug 27, 2013 3:41 pm

Thanks for the feedback. You are right. Pari uses these functions heavily. So I am stuck at this for this moment....

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests