473,498 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hello world not working on Unix :(

Hi guys,

I've tried a hello world script:

#include <iostream>

int main() {
using namespace std;

cout << "Hello!\n";
return 0;
}

But I've got an error message:

gcc test.cpp
/var/tmp//ccZLLi7M.o(.text+0xd): In function `std::__verify_grouping(char
const*, unsigned int, std::string const&)':
: undefined reference to `std::string::size() const'
/var/tmp//ccZLLi7M.o(.text+0x60): In function `std::__verify_grouping(char
const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccZLLi7M.o(.text+0x9d): In function `std::__verify_grouping(char
const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccZLLi7M.o(.text+0xc8): In function `std::__verify_grouping(char
const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccZLLi7M.o(.text+0x121): In function `main':
: undefined reference to `std::cout'
/var/tmp//ccZLLi7M.o(.text+0x126): 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*)'
/var/tmp//ccZLLi7M.o(.text+0x152): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/var/tmp//ccZLLi7M.o(.text+0x183): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/var/tmp//ccZLLi7M.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'

I'm on PC-BSD. Any idea?
Thanks,

Charles.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 7 '05 #1
4 6279
* Charles:
Hi guys,

I've tried a hello world script:
That's a C++ program. C++ programmers will be _very angry_ if you tell them
that C++ is a scripting language. You have been Warned. ;-)

#include <iostream>

int main() {
using namespace std;

cout << "Hello!\n";
return 0;
}

But I've got an error message:

gcc test.cpp


Use 'g++' instead of 'gcc'; 'g++' uses 'gcc' internally but in addition
instructs the linker to add necessary C++ libraries, which you're lacking when
you use 'gcc' directly and not specifying them yourself.

Next time, please ask in a compiler/system-specific group about such
questions, since this group is concerned only with the C++ _language_, not the
tools (in general).

Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 7 '05 #2
Indeed! It's working fine now.
Thank you Alf!

On Fri, 07 Oct 2005 01:56:20 -0000, Alf P. Steinbach <al***@start.no>
wrote:
* Charles:
Hi guys,

I've tried a hello world script:


That's a C++ program. C++ programmers will be _very angry_ if you tell
them
that C++ is a scripting language. You have been Warned. ;-)

#include <iostream>

int main() {
using namespace std;

cout << "Hello!\n";
return 0;
}

But I've got an error message:

gcc test.cpp


Use 'g++' instead of 'gcc'; 'g++' uses 'gcc' internally but in addition
instructs the linker to add necessary C++ libraries, which you're
lacking when
you use 'gcc' directly and not specifying them yourself.

Next time, please ask in a compiler/system-specific group about such
questions, since this group is concerned only with the C++ _language_,
not the
tools (in general).

Cheers,

- Alf


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 7 '05 #3
That's a C++ program. C++ programmers will be _very angry_ if you tell


Alf -
C++ can be (and at times should be) called scripting language. Lot's
of .bat scripts had, previously, been written by C/C++. Additionally,
scripts written in C++ grammar run faster than any bash or others...
Sometimes it is useful, and perhaps psychologically helpful, to admit
your disgraceful defeat.

Oct 7 '05 #4
* puzzlecracker:
That's a C++ program. C++ programmers will be _very angry_ if you tell


C++ can be (and at times should be) called scripting language.


That's right, e.g. <url: http://root.cern.ch/root/Cint.html>.

In the same sense as a shoe heel can be called a hammer, in certain contexts.

However, C++ is not a scripting language; for an explanation of "scripting
language" see <url: http://en.wikipedia.org/wiki/Scripting_language> (which
unfortunately does not link to CINT, but instead, misleadingly, to Ch).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 7 '05 #5

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

Similar topics

6
2155
by: Robert Maas, see http://tinyurl.com/uh3t | last post by:
System login message says PHP is available, so I tried this: http://www.rawbw.com/~rem/HelloPlus/h.php It doesn't work at all. Browser just shows the source. What am I doing wrong?
4
4431
by: Fritz Kaufmann | last post by:
Hello There I have a problem. I'm a beginner and try to get the following program working. It has an exception. Can you tell me? public class Hello{ public static void main (String args){...
2
3624
by: Helge Stenstrom | last post by:
I'd like to do something similar to a Hello World program, namely a few Windows error messages, as jokes. (Something similar to http://shotgun.shacknet.nu:81/noterror.jpg) Hopefully, Python is a...
6
4101
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
21
4069
by: Alf P. Steinbach | last post by:
Just because there seems to be a lack of post-standard _correct_ tutorials: <url: http://home.no.net/dubjai/win32cpptut/>. Disclaimer: written this evening so perhaps there are "bugs" in the...
30
3756
by: Dave -Turner | last post by:
So I just downloaded Bloodshed devcpp, opened up the Hello example, compiled it, no problems ..... well, except one - the exe is 474,990 bytes! What's the secret to compiling small exes? Thanks
11
2975
by: cj | last post by:
Perhaps someone knows how to do this. When I open a new ASP.NET web service application in VS 2008, it opens with a simple Hello World web service already written. I want to see this work. ...
2
6626
by: EdKing | last post by:
Hi everyone, I'm currently trying to get the simplest "Hello World!" Python script working on a Telit GM862-GPS. I have succeeded in writing to the Telit via the Hyper Terminal and can confirm...
0
2557
by: tosreejithp | last post by:
Hi, My first problem was i am not able to compiled a file from java script to java class.Now its clear and working fine..now i can convert a java script file to java class by Rhino Java Script...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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
7165
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,...
1
6887
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
7379
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
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.