473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Can't compile HW

I'm just beginning and I'm having trouble starting. Can't get this to
compile and could use some direction.

#include <iostream>
using namespace std;

int main () {
cout << "Hello World" << endl;
}

Here are the particulars:
uname -a
Linux tegary-lnx 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686
i386 GNU/Linux

gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

gcc hw.cc
/tmp/ccIWkyfm.o(.text+0x14): In function `main':
: undefined reference to `std::basic_ostream<char,
std::char_traits<char& std::endl<char, std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char&)'
/tmp/ccIWkyfm.o(.text+0x21): In function `main':
: undefined reference to `std::cout'
/tmp/ccIWkyfm.o(.text+0x26): In function `main':
: undefined reference to `std::basic_ostream<char,
std::char_traits<char& std::operator<< <std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char&, char const*)'
/tmp/ccIWkyfm.o(.text+0x2f): In function `main':
: undefined reference to `std::basic_ostream<char,
std::char_traits<char::operator<<(std::basic_ostre am<char,
std::char_traits<char& (*)(std::basic_ostream<char,
std::char_traits<char&))'
/tmp/ccIWkyfm.o(.text+0x5c): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccIWkyfm.o(.text+0x8b): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccIWkyfm.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

Didn't think I'd need help this early.
TIA
Gary

Aug 25 '06 #1
5 1546
"vcgeek" <vc****@gmail.comwrote...
I'm just beginning and I'm having trouble starting. Can't get this to
compile and could use some direction.

[...]
gcc hw.cc
[..]
Don't use gcc, use g++. Next time you have a problem using gcc or g++
please post to 'gnu.gcc.help' or 'gnu.g++.help'.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 25 '06 #2

Victor Bazarov wrote:
"vcgeek" <vc****@gmail.comwrote...
I'm just beginning and I'm having trouble starting. Can't get this to
compile and could use some direction.

[...]
gcc hw.cc
[..]

Don't use gcc, use g++. Next time you have a problem using gcc or g++
please post to 'gnu.gcc.help' or 'gnu.g++.help'.
Thanks for g++ that appears to work. I had tried it earlier but must
have had some other problem. The doc sounds like either should work.

Also thanks for the correct group with out the flames.

Gary

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 25 '06 #3
vcgeek posted:
I'm just beginning and I'm having trouble starting. Can't get this to
compile and could use some direction.

#include <iostream>
using namespace std;

int main () {
cout << "Hello World" << endl;
}

First, I'd recommend changing that to:

#include <ostream>
#include <iostream>

using std::cout;
using std::endl;

int main()
{
cout << "Hello World" << endl;
}

gcc hw.cc

You're using the C compiler, not the C++ compiler.

Have you tried Dev-C++? I use it and it's pretty handy.

--

Frederick Gotham
Aug 25 '06 #4
vcgeek wrote:
>
Victor Bazarov wrote:
"vcgeek" <vc****@gmail.comwrote...
I'm just beginning and I'm having trouble starting. Can't get
this to compile and could use some direction.
>
[...]
gcc hw.cc
[..]
Don't use gcc, use g++. Next time you have a problem using gcc or
g++ please post to 'gnu.gcc.help' or 'gnu.g++.help'.

Thanks for g++ that appears to work. I had tried it earlier but must
have had some other problem. The doc sounds like either should work.
Either will compile the code. What g++ does for you is link the proper
libraries.


Brian (thinks it seems needlessly tricky)
Aug 25 '06 #5
In article <11**********************@m73g2000cwd.googlegroups .com>,
vc****@gmail.com says...

[ ... compiling C++ with: ]
gcc hw.cc
Try using "g++" instead of "gcc" and see it if doesn't help. Otherwise,
you're probably better off asking somewhere related to gcc rather than
C++. Here we discuss the language itself, not things like how to install
and use compilers (I know it sounds picky, but keep in mind that even
with the restricted range of topics, the volume here is already quite
high).

--
Later,
Jerry.

The universe is a figment of its own imagination.
Aug 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: zhouhaiming | last post by:
On our test machine I can compile my c source code on AIX5.1(ML4) by "- q32" option and "OBJECT_MODE=32" environment variable, and it can correctly running. My operation system environment is:...
0
by: Jordan Willms | last post by:
My xsl stylesheet is as simple as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2"...
8
by: Davy | last post by:
Hi all, I use VC and gcc/gdb to compile and debug C/C++ files. But I found some of the debug version of the compiled files are too large to be run in a small RAM. Can I compile C/C++ Debug...
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
4
by: Chronologic | last post by:
All, I have an issue I would like some expert help on. I understand, or so I believe, that C# does not support the concept of a "compile time macro". At least not in the sense I'm looking...
10
by: Jordan | last post by:
I would like to take my ASP.NET project to another computer, which doesn't have Visual Studio. If I modify the code there, is there a way to recompile it without Visual Studio? Thanks!
5
by: MLH | last post by:
A97 aborts creation of MDE reporting that there's a compile error in one form. Sure enough, if I remove the form from the source database and attempt to compile the MDE, it succeeds. But when I...
12
by: Ark | last post by:
Hello NG, I arrange data in structs like { members... uint16_t crc; more members, maybe... } Then I need to save them, up to and including crc, in non-volatile memory or a file, as the case...
15
by: steve yee | last post by:
i want to detect if the compile is 32 bits or 64 bits in the source code itself. so different code are compiled respectively. how to do this?
3
by: NvrBst | last post by:
Right now I have C99 code in .c extensions. I compile it in VSC++ and it complains about a lot of errors. I change the extensions to .cpp and compile in VSC++ and it succeeds. Is there a way...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.