Compilation error in "Hello World" program.

Discussion in 'C++' started by PG, May 7, 2004.

  1. PG

    PG Guest

    Hi gurus,

    I have AIX visual age C++ compiler version 5.0.2.3. I have a simple
    hello world program that gives compilation errors. Any help will be
    appreciated. Thanks

    PG
    ***test.cpp****

    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.h>

    int main()
    {
    cout << "Hello World" << endl;
    return 0;
    }
    ***end test.cpp****

    ****Errors:****
    $ cc test.cpp
    "/usr/vacpp/include/stdlib.h", line 123.13: 1540-0040 (S) The text
    "llabs" is unexpected. "undef" may be undeclared or ambiguous.
    ****End of Errors:****


    ****Software Version****
    lslpp -l | grep vacpp

    vacpp.Dt.common 5.0.2.0 COMMITTED VisualAge C++ Desktop
    vacpp.Dt.ide 5.0.2.0 COMMITTED VisualAge C++ IDE
    Desktop
    vacpp.Dt.techide 5.0.2.0 COMMITTED VisualAge C++ IDE
    Tech Preview
    vacpp.cmp.C 5.0.2.0 COMMITTED VisualAge C++ C
    Compiler
    vacpp.cmp.aix50.lib 5.0.2.4 COMMITTED VisualAge C++
    Libraries for
    vacpp.cmp.batch 5.0.2.4 COMMITTED VisualAge C++ Batch
    Compiler
    vacpp.cmp.core 5.0.2.3 COMMITTED VisualAge C++
    Compiler
    vacpp.cmp.extension 5.0.2.3 COMMITTED VisualAge C++
    Extension
    vacpp.cmp.include 5.0.2.4 COMMITTED VisualAge C++
    Compiler Include
    vacpp.cmp.incremental 5.0.2.3 COMMITTED VisualAge C++
    Incremental
    vacpp.cmp.lib 5.0.2.4 COMMITTED VisualAge C++
    Libraries
    vacpp.cmp.rte 5.0.2.0 COMMITTED VisualAge C++
    Compiler
    vacpp.cmp.tools 5.0.2.4 COMMITTED VisualAge C++ Tools
    vacpp.html.EN_US 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.SBCS 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.common 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.en_US 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.help 5.0.2.0 COMMITTED VisualAge C++ HTML
    Help Engine
    vacpp.ide 5.0.2.3 COMMITTED VisualAge C++ IDE
    vacpp.ioc.aix50.rte 5.0.2.1 COMMITTED IBM Open Class
    Library AIX 5.0
    vacpp.ioc.rte 5.0.2.1 COMMITTED IBM Open Class
    Library
    vacpp.lic 5.0.2.0 COMMITTED VisualAge C++ Licence
    Files
    vacpp.loc.en_US.cmp.core 5.0.2.3 COMMITTED VisualAge Compiler
    C++ Locale
    vacpp.msg.en_US.cmp.batch 5.0.2.0 COMMITTED VisualAge Batch
    Compiler C++
    vacpp.msg.en_US.cmp.core 5.0.2.3 COMMITTED VisualAge Compiler
    C++
    vacpp.msg.en_US.cmp.tools 5.0.2.0 COMMITTED VisualAge C++ Tools
    vacpp.msg.en_US.html.help 5.0.2.0 COMMITTED VisualAge C++ Help
    Engine
    vacpp.msg.en_US.ide 5.0.2.3 COMMITTED VisualAge C++ IDE
    vacpp.msg.en_US.ioc.rte 5.0.2.1 COMMITTED IBM Open Class
    Library Runtime
    vacpp.msg.en_US.rescmp 5.0.2.0 COMMITTED VisualAge C++
    Resource
    vacpp.rescmp 5.0.2.0 COMMITTED VisualAge C++
    Resource
    vacpp.Dt.common 5.0.2.0 COMMITTED VisualAge C++ Desktop
    vacpp.Dt.ide 5.0.2.0 COMMITTED VisualAge C++ IDE
    Desktop
    vacpp.Dt.techide 5.0.2.0 COMMITTED VisualAge C++ IDE
    Tech Preview
    vacpp.cmp.core 5.0.2.3 COMMITTED VisualAge C++
    Compiler
    vacpp.html.EN_US 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.SBCS 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.common 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.en_US 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.help 5.0.2.0 COMMITTED VisualAge C++ HTML
    Help Engine
    vacpp.loc.en_US.cmp.core 5.0.2.3 COMMITTED VisualAge Compiler
    C++ Locale
    ****End of Software Version****
     
    PG, May 7, 2004
    #1
    1. Advertisements

  2. PG

    Bill Seurer Guest

    You don't need those.
     
    Bill Seurer, May 7, 2004
    #2
    1. Advertisements

  3. Non standard header file.
    If a compiler can't compile its own header files that would indicate to me
    that it is wrongly installed. Obviously that is beyond the scope of this
    group.

    However you might like to try the following legal C++ program (yours was not
    legal) to see if you get any further.

    #include <iostream>

    int main()
    {
    std::cout << "hello, world\n";
    }

    Note the name of the header file <iostream>, <iostream.h> is not a standard
    C++ header file. Also note the use of std::cout rather than cout.

    I don't think either of these corrections explain the error message above
    however.

    john
     
    John Harrison, May 7, 2004
    #3
  4. Well no, but's it not incorrect to have them.

    Unlike the above header.

    john
     
    John Harrison, May 7, 2004
    #4
  5. PG

    Jeff Herrick Guest

    A couple of things

    1) do a 'which cc' and make sure you're pointing to /usr/vacpp/bin
    and not /usr/vac/bin. If you're pointing to 'vac' then modify
    your PATH to add /usr/vacpp/bin to the front of it.

    2) use xlC instead of cc

    3) Don't call the program 'test' ... there's a Unix command of the
    same name and if you don't have '.' in your PATH, you're going
    to be even more confused when you get it compiled =:cool:

    Cheers

    Jeff Herrick

    ps...Notwithstanding the other remarks re your header files, your
    example compiles and links okay on my 5.1 box when I follow
    the steps above
     
    Jeff Herrick, May 7, 2004
    #5
  6. PG

    joe Guest

    Are you sure 'cc' is a C++ compiler? On the AIX box I have access to
    the C++ compiler is called xlC, and cc is a C compiler.

    Joe
     
    joe, May 7, 2004
    #6
  7. PG

    Gary R. Hook Guest

    Good point, plus the fact that the V5 compiler is out of service,
    and their install is woefully back-level (you can still get the
    5.0.2.9 update from the service website).
     
    Gary R. Hook, May 7, 2004
    #7
  8. ????
    cc merely invokes xlC with certain default options. xlC is the C
    compiler you need vacpp or some such to do c++, no?
     
    Timothy J. Bogart, May 7, 2004
    #8
  9. PG

    joe Guest

    Well, on our machines, xlc invokes the C compiler with configured
    options. xlC invokes the C++ compiler with configured options. I'm not
    sure how 'cc' fits into this scheme, hence my question.

    Joe
     
    joe, May 7, 2004
    #9
  10. PG

    sbzx Guest

    This seems to be a known issue, see APAR IY23677 (TEXT "LLABS"
    UNEXPECTED COMPILING STDLIB.H).

    Cheers,
    z
     
    sbzx, May 8, 2004
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.