Compilation error in "Hello World" program.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PG

    Compilation error in "Hello World" program.

    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.techid e 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.exten sion 5.0.2.3 COMMITTED VisualAge C++
    Extension
    vacpp.cmp.inclu de 5.0.2.4 COMMITTED VisualAge C++
    Compiler Include
    vacpp.cmp.incre mental 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_U S 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.SBCS 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.comm on 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.en_U S 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.techid e 5.0.2.0 COMMITTED VisualAge C++ IDE
    Tech Preview
    vacpp.cmp.core 5.0.2.3 COMMITTED VisualAge C++
    Compiler
    vacpp.html.EN_U S 5.0.0.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.SBCS 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.comm on 5.0.2.0 COMMITTED VisualAge C++
    Documentation
    vacpp.html.en_U S 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****
  • John Harrison

    #2
    Re: Compilation error in &quot;Hello World&quot; program.


    "PG" <pg_promo@yahoo .com> wrote in message
    news:12d6f29a.0 405070901.cb24a 5d@posting.goog le.com...[color=blue]
    > 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>[/color]

    Non standard header file.
    [color=blue]
    >
    > 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:****[/color]

    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



    Comment

    • Bill Seurer

      #3
      Re: Compilation error in &quot;Hello World&quot; program.

      PG wrote:
      [color=blue]
      > #include <stdio.h>
      > #include <stdlib.h>[/color]

      You don't need those.
      [color=blue]
      > #include <iostream.h>
      >
      > int main()
      > {
      > cout << "Hello World" << endl;
      > return 0;
      > }[/color]

      Comment

      • John Harrison

        #4
        Re: Compilation error in &quot;Hello World&quot; program.


        "Bill Seurer" <seurer@us.ibm. com> wrote in message
        news:c7gfih$1k0 m$1@news.rchlan d.ibm.com...[color=blue]
        > PG wrote:
        >[color=green]
        > > #include <stdio.h>
        > > #include <stdlib.h>[/color]
        >
        > You don't need those.
        >[/color]

        Well no, but's it not incorrect to have them.
        [color=blue][color=green]
        > > #include <iostream.h>[/color][/color]

        Unlike the above header.

        john


        Comment

        • Jeff Herrick

          #5
          Re: Compilation error in &quot;Hello World&quot; program.


          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 =8-)

          Cheers

          Jeff Herrick

          ps...Notwithsta nding the other remarks re your header files, your
          example compiles and links okay on my 5.1 box when I follow
          the steps above

          On 7 May 2004, PG wrote:
          [color=blue]
          > Hi gurus,
          >
          > [snip][/color]

          Comment

          • joe@invalid.address

            #6
            Re: Compilation error in &quot;Hello World&quot; program.

            pg_promo@yahoo. com (PG) writes:
            [color=blue]
            > 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:****[/color]

            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
            --
            "Surprise me"
            - Yogi Berra when asked where he wanted to be buried.

            Comment

            • Gary R. Hook

              #7
              Re: Compilation error in &quot;Hello World&quot; program.

              joe@invalid.add ress wrote:
              [color=blue]
              > 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.[/color]

              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 / AIX PartnerWorld for Developers / These opinions are MINE
              _______________ _______________ _______________ _______________ ____________

              Comment

              • Timothy J. Bogart

                #8
                Re: Compilation error in &quot;Hello World&quot; program.

                Gary R. Hook wrote:[color=blue]
                > joe@invalid.add ress wrote:
                >[color=green]
                >> 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.[/color]
                >
                >
                > 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).
                >[/color]
                ????
                cc merely invokes xlC with certain default options. xlC is the C
                compiler you need vacpp or some such to do c++, no?

                Comment

                • joe@invalid.address

                  #9
                  Re: Compilation error in &quot;Hello World&quot; program.

                  "Timothy J. Bogart" <tbogart@frii.n et> writes:
                  [color=blue]
                  > Gary R. Hook wrote:[color=green]
                  > > joe@invalid.add ress wrote:
                  > >[color=darkred]
                  > >> 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.[/color]
                  > > 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).
                  > >[/color]
                  > ????
                  > cc merely invokes xlC with certain default options. xlC is the C
                  > compiler you need vacpp or some such to do c++, no?[/color]

                  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
                  --
                  "Surprise me"
                  - Yogi Berra when asked where he wanted to be buried.

                  Comment

                  • sbzx

                    #10
                    Re: Compilation error in &quot;Hello World&quot; program.

                    pg_promo@yahoo. com (PG) wrote in message news:<12d6f29a. 0405070901.cb24 a5d@posting.goo gle.com>...[color=blue]
                    > 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:****[/color]

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

                    Cheers,
                    z

                    Comment

                    Working...