AIX Open Source

 View Only
  • 1.  g++ cstdlib - 'exit' has not been declared

    IBM Champion
    Posted Thu December 02, 2021 03:47 AM
    Code:

    #include <cstdlib>

    int main() {
    exit(1);
    }

    As you may expect, it works perfectly on every operating system except AIX :-)

    gcc 8.3.0 with libstdc++ 8.3.0 are installed:

    #rpm -qa | grep gcc | sort
    gcc-8-1.ppc
    gcc-c++-8-1.ppc
    gcc-cpp-8-1.ppc
    gcc8-8.3.0-6.ppc
    gcc8-c++-8.3.0-6.ppc
    gcc8-cpp-8.3.0-6.ppc
    libgcc-8-1.ppc
    libgcc8-8.3.0-6.ppc
    #rpm -qa | grep libstdc | sort
    libstdc++-8-1.ppc
    libstdc++8-8.3.0-6.ppc
    libstdc++8-devel-8.3.0-6.ppc

    Trying to compile it on AIX I'm getting the following error messages:

    #g++ test.cpp
    In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/cstdlib:75,
    from test.cpp:1:
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/stdlib.h:341:25: error: 'exit' has not been declared
    extern _NORETURN(void, exit)(int);
    ^~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/stdlib.h:341:34: error: '_NORETURN' declared as function returning a function
    extern _NORETURN(void, exit)(int);
    ^
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/stdlib.h:353:25: error: 'quick_exit' has not been declared
    extern _NORETURN(void, quick_exit)(int);
    ^~~~~~~~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/stdlib.h:353:40: error: '_NORETURN' declared as function returning a function
    extern _NORETURN(void, quick_exit)(int);
    ^
    In file included from test.cpp:1:
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/cstdlib:146:11: error: '::exit' has not been declared
    using ::exit;
    ^~~~
    /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/cstdlib:160:11: error: '::quick_exit' has not been declared
    using ::quick_exit;
    ^~~~~~~~~~
    test.cpp: In function 'int main()':
    test.cpp:4:3: error: 'exit' was not declared in this scope
    exit(1);
    ^~~~
    test.cpp:4:3: note: suggested alternative: 'ecvt'
    exit(1);
    ^~~~
    ecvt


    What am I missing / doing wrong here?

    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------


  • 2.  RE: g++ cstdlib - 'exit' has not been declared

    IBM Champion
    Posted Thu December 02, 2021 07:23 AM
    I checked now on AIX 7.3 Open Beta with gcc 10 and it works as expected. What was changed and when can we have gcc10 on AIX 7.2/7.1?

    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 3.  RE: g++ cstdlib - 'exit' has not been declared

    Posted Fri December 03, 2021 09:02 AM
    Edited by SANKET RATHI Fri December 03, 2021 09:02 AM
    Hi Andrey, 

    What version of AIX you used when you see error with gcc-8 ?
    Output of "oslevel -s"

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 4.  RE: g++ cstdlib - 'exit' has not been declared

    Posted Fri December 03, 2021 09:05 AM
    I did not see any issue with gcc-8 on my system 

    # oslevel -s
    7200-05-03-2147

    # g++ test.cpp

    # cat test.cpp
    #include <cstdlib>

    int main() {
    exit(1);
    }

    # rpm -qa | grep gcc
    libgcc8-8.3.0-6.ppc
    gcc8-8.3.0-6.ppc
    gcc-cpp-8-1.ppc
    gcc-c++-8-1.ppc
    libgcc-8-1.ppc
    gcc8-cpp-8.3.0-6.ppc
    gcc-8-1.ppc
    gcc8-c++-8.3.0-6.ppc

    #

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 5.  RE: g++ cstdlib - 'exit' has not been declared

    Posted Fri December 03, 2021 09:10 AM
    Did you do update recently on newer AIX 72 level ? 
    In that case probably you will see issue. 
    There were changes in AIX header files and those might not be there in the gcc include fix hence there is a mismatch.
    For gcc working gcc takes AIX header files and make some changes and uses them the fix headers it put in /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/path
    This happens at the gcc install time. So if you have installed gcc on AIX and then recently updated AIX (where new header files are added) then those changes will not be there in gcc include-fix path. To bring the include in gcc include-fix you can reinstall gcc. 
    Try to reinstall latest gcc from AIX toolbox and see if issue goes away.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 6.  RE: g++ cstdlib - 'exit' has not been declared

    IBM Champion
    Posted Fri December 03, 2021 10:40 AM
    Edited by Andrey Klyachkin Fri December 03, 2021 10:40 AM
    Hi Sanket,

    it is AIX 7.2 TL5 SP3 and yes, it was recently updated (from SP1 or SP2 to SP3).

    As you proposed, I reinstalled gcc/g++ and it helped. Thank you!

    Is it possible to get postinstall script from gcc8 as a separate script, which can be run after an AIX update? It would be faster than reinstalling the packages.


    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 7.  RE: g++ cstdlib - 'exit' has not been declared

    Posted Mon December 06, 2021 02:49 AM
    Hi Andrey, 
    Yes we thought about it and in near future we will see how can we provide steps to run that scripts so that after AIX update user can manually run script.

    ------------------------------
    SANKET RATHI
    ------------------------------