[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libapl stdout

From: Chris Moller
Subject: Re: libapl stdout
Date: Fri, 27 Jan 2023 11:23:08 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

For what it's worth, in an ongoing project in use:

#include <QtWidgets>

#include <iostream>
#include <sstream>

#include <apl/libapl.h>

#include "aplexec.h"

AplExec::aplExec (apl_op_e apl_op, QString &cmd,
          QString &outString, QString &errString)
 LIBAPL_error execerr = LAE_NO_ERROR;

 switch(apl_op) {
 case APL_OP_EXEC:
     std::stringstream outbuffer;
     std::streambuf *coutbuf = std::cout.rdbuf();
     std::stringstream errbuffer;
     std::streambuf *cerrbuf = std::cerr.rdbuf();
     execerr = apl_exec (cmd.toStdString ().c_str ());
     outString = QString (outbuffer.str ().c_str ());
     errString = QString (errbuffer.str ().c_str ());
     std::stringstream errbuffer;
     std::streambuf *cerrbuf = std::cerr.rdbuf();
     const char *res = apl_command (cmd.toStdString ().c_str ());
     if (res) {
       outString = QString (res);
       free ((void *)res);
     errString = QString (errbuffer.str ().c_str ());

 return execerr;

I.e., I'm capturing stdout and stderr in strings.

On 1/27/23 10:18, Dr. Jürgen Sauermann wrote:
Hi enztec,

not sure if this helps, but if I remember correctly (I may not) then the main GNU APL output
goes to *stderr* (fd 2) and not to *stdout* (fd 1). The reason is somewhat historic because *stdout* is
buffered by default while *stderr* is not (which caused some issues with *stdout* when used
interactively that did not occur with *stderr*).

Best Regads,

On 1/15/23 12:19 AM, enztec@gmx.com wrote:

I'm still trying to resolve the failure of fpc using libapl to get it's stdout

trying to get libapl stdout to be gotten in my libapl/fpc program i read the

thinking fpc might be using a different stdout then the libapl does from this line
'but because the executable that is linked with libapl.so) has its own I/O channels.'

and re-compiled libapl with --with-android
and then compiling my program i get get :

/usr/local/lib/apl/libapl.so: undefined reference to `CIN'
/usr/local/lib/apl/libapl.so: undefined reference to `UERR'
/usr/local/lib/apl/libapl.so: undefined reference to `COUT'
/usr/local/lib/apl/libapl.so: undefined reference to `CERR'

is this suppose to happen ?

i get same error when compiling my libaplo.c program

how to set these in the c program?

Attachment: OpenPGP_0xDA6C01938888083E.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]