Page 1 of 1

pipe functions

Posted: Sat Aug 17, 2013 9:59 am
by joaopa
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

Re: pipe functions

Posted: Wed Aug 21, 2013 3:16 pm
by mtheall
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.

Re: pipe functions

Posted: Tue Aug 27, 2013 3:41 pm
by joaopa
Thanks for the feedback. You are right. Pari uses these functions heavily. So I am stuck at this for this moment....