Operating System - HP-UX
1752805 Members
5428 Online
108789 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
chilabot
Occasional Advisor

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' ?

10 REPLIES 10
Dennis Handly
Acclaimed Contributor

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

>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.

Steven Schweda
Honored Contributor

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

 
chilabot
Occasional Advisor

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

[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? 

Steven Schweda
Honored Contributor

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

 
chilabot
Occasional Advisor

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. 

 

Steven Schweda
Honored Contributor

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

 
chilabot
Occasional Advisor

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' ?

 

Steven Schweda
Honored Contributor
Solution

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

 
Dennis Handly
Acclaimed Contributor

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.