Re: error: 'rexec' was not declared in this scope (543 Views)
Reply
Occasional Advisor
Posts: 8
Registered: ‎10-22-2012
Message 1 of 11 (620 Views)
Accepted Solution

error: 'rexec' was not declared in this scope

Simple program:

 

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netdb.h>

int main(int argc, char **argv)
{
    int ret = rexec((char**) 0, "", "", "", 0);

    return 0;
}

g++ -o rexec -D_XOPEN_SOURCE_EXTENDED rexec.cpp

 

rexec.cpp: In function 'int main(int, char**)':
rexec.cpp:10:49: error: 'rexec' was not declared in this scope

 

ref: http://stackoverflow.com/questions/12955644/rexec-not-found-in-hp-ux

 

where is 'rexec' ?

Acclaimed Contributor
Posts: 25,715
Registered: ‎03-06-2006
Message 2 of 11 (609 Views)

Re: error: 'rexec' was not declared in this scope

[ Edited ]

>where is rexec ?

 

It's in <sys/socket.h> but you can't compile with -D_XOPEN_SOURCE_EXTENDED since rexec(3) isn't in that namespace.

And you have the wrong number/type of parms.

Honored Contributor
Posts: 9,121
Registered: ‎02-23-2005
Message 3 of 11 (610 Views)

Re: error: 'rexec' was not declared in this scope

Occasional Advisor
Posts: 8
Registered: ‎10-22-2012
Message 4 of 11 (587 Views)

Re: error: 'rexec' was not declared in this scope

[ Edited ]

[gimenero@rx8km ~]$ uname -a

HP-UX rx8km B.11.31 U ia64 2229485251 unlimited-user license

 

[gimenero@rx8km ~]$ g++ -v

Using built-in specs.

COLLECT_GCC=g++

COLLECT_LTO_WRAPPER=/opt/hp-gcc-4.7.0/libexec/gcc/ia64-hp-hpux11.23/4.7.0/lto-wrapper

Target: ia64-hp-hpux11.23

Configured with: /tmp/gcc-4.7.0.tar.gz/gcc-4.7.0/configure --host=ia64-hp-hpux11.23 --target=ia64-hp-hpux11.23 --build=ia64-hp-hpux11.23 --prefix=/opt/hp-gcc-4.7.0 --with-gnu-as --without-gnu-ld --enable-threads=posix --enable-languages=c,c++ --with-gmp=/proj/opensrc/be/ia64-hp-hpux11.23 --with-mpfr=/proj/opensrc/be/ia64-hp-hpux11.23

SED=/usr/bin/sed

Thread model: posix

gcc version 4.7.0 (GCC)

 

 

i'm compiling with -D_XOPEN_SOURCE_EXTENDED because that compiles most of my ported code (from solaris). What flag should I use so the code can be portable between linux, solaris and hp-ux? 

Honored Contributor
Posts: 9,121
Registered: ‎02-23-2005
Message 5 of 11 (584 Views)

Re: error: 'rexec' was not declared in this scope

Occasional Advisor
Posts: 8
Registered: ‎10-22-2012
Message 6 of 11 (582 Views)

Re: error: 'rexec' was not declared in this scope

the problem is that with _XOPEN_SOURCE_EXTENDED i can compile all my code but this, is there a flag that i can add so 'rexec' whould appear? i mostly use the boost libraries so i save a lot of portability issues with it. 

 

Honored Contributor
Posts: 9,121
Registered: ‎02-23-2005
Message 7 of 11 (579 Views)

Re: error: 'rexec' was not declared in this scope

Occasional Advisor
Posts: 8
Registered: ‎10-22-2012
Message 8 of 11 (569 Views)

Re: error: 'rexec' was not declared in this scope

i've just declared it myself: 

 

int rexec (char **, int, const char *, const char *, const char *, int *);

 

in that particular program, it compiles, but in another bigger one, the symbol is missing:

 

ld: Unsatisfied symbol "rexec(char**, int, char const*, char const*, char const*, int*)" in file ...

 

do you know in which library is 'rexec' ?

 

Honored Contributor
Posts: 9,121
Registered: ‎02-23-2005
Message 9 of 11 (563 Views)

Re: error: 'rexec' was not declared in this scope

Acclaimed Contributor
Posts: 25,715
Registered: ‎03-06-2006
Message 10 of 11 (559 Views)

Re: error: 'rexec' was not declared in this scope

>I'm compiling with -D_XOPEN_SOURCE_EXTENDED because that compiles most of my ported code (from solaris).

 

Does the default -D_HPUX_SOURCE compile everything?

 

>but "#ifndef _XOPEN_SOURCE_EXTENDED" looks to me to be rather rigid.

 

Right, rexec isn't part of that namespace.

 

>do you know in which library is 'rexec' ?

 

libc.so.1

 

>ld: Unsatisfied symbol "rexec(char**, int, char const*, char const*, char const*, int*)" in file ...

 

As Steven said, you forgot to C++ify your source with extern "C".  You have an unsat with a mangled name.

Occasional Advisor
Posts: 8
Registered: ‎10-22-2012
Message 11 of 11 (543 Views)

Re: error: 'rexec' was not declared in this scope

you're right, I forgot to extern "C" it. Now it compiles. Thanks!

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.