Compilation error in "Hello World" program.

P

PG

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****
 
J

John Harrison

PG said:
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>

Non standard header file.
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:****

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
 
J

Jeff Herrick

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
 
J

joe

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:****

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
 
G

Gary R. Hook

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.

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

Timothy J. Bogart

Gary said:
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).
????
cc merely invokes xlC with certain default options. xlC is the C
compiler you need vacpp or some such to do c++, no?
 
J

joe

Timothy J. Bogart said:
????
cc merely invokes xlC with certain default options. xlC is the C
compiler you need vacpp or some such to do c++, no?

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
 
S

sbzx

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:****

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

Cheers,
z
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top