473,890 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

undefined reference to std::cout

1 New Member
i program under linux ,and using kdevelop c/c++.
the code follow,
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello, from Win32!" << endl;

return EXIT_SUCCESS;
}
when #gcc -p ty.cpp
error :
root@localhost src]# gcc -p ty.cpp
/tmp/ccsuKY9I.o(.tex t+0x2a): In function `main':
ty.cpp: undefined reference to `std::cout'
/tmp/ccsuKY9I.o(.tex t+0x2f):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >& std::operator<< <std::char_trai ts<char> >(std::basic_os tream<char, std::char_trait s<char> >&, char const*)'
/tmp/ccsuKY9I.o(.tex t+0x3a):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >& std::endl<char, std::char_trait s<char> >(std::basic_os tream<char, std::char_trait s<char> >&)'
/tmp/ccsuKY9I.o(.tex t+0x40):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >::operator<<(s td::basic_ostre am<char, std::char_trait s<char> >& (*)(std::basic_ ostream<char, std::char_trait s<char> >&))'
/tmp/ccsuKY9I.o(.tex t+0x62): In function `__tcf_0':
ty.cpp: undefined reference to `std::ios_base: :Init::~Init()'
/tmp/ccsuKY9I.o(.tex t+0x8f): In function `__static_initi alization_and_d estruction_0(in t, int)':
ty.cpp: undefined reference to `std::ios_base: :Init::Init()'
/tmp/ccsuKY9I.o(.eh_ frame+0x11): undefined reference to `__gxx_personal ity_v0'
collect2: ld returned 1 exit status

how to solove this problem
think you .i use linux for a few days .
Jun 7 '07 #1
1 10942
Motoma
3,237 Recognized Expert Specialist
What version of gcc and kdevelop are you using?

You will probably need to run the ./configure script that kdevelop creates for you.
Jun 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3309
by: Pmb | last post by:
I've noticed a lot of people preferring std::cout over cout. May I ask why you prefer one over the other? thanks Pmb
12
3574
by: Minti | last post by:
Is std::cout slower than printf When we call printf e.g. in printf(20 format conversion specifications, 20 arguments); Is it faster than the std::cout << { 20 redirections to the output stream }
6
2373
by: clilley | last post by:
The following code causes a segmentation fault on DEC Tru64: foo.cc (built into libFoo.so) //--------------------------- include <iostream> bool createFoo() { std::cout << "createFoo" << std::endl; }
3
1645
by: Jason Heyes | last post by:
I have a function that reads tags. The function prints any failures it encounters to std::cout. std::istream &read_tag(std::istream &is, std::string &tag) { std::string s; if (!(is >> s)) { std::cout << "Failed to read string of tag" << std::endl; return is;
19
33488
by: Dancefire | last post by:
Hi, everyone It might be a simple question, but I really don't know the answer. char c = '1'; cout << c; The above code will only output a '1' rather than 0x31; If I use int cast, it can show the number:
6
60997
by: Roger | last post by:
Hello, I'm pretty new to C++ programming, and I'm teaching myself the language using various sources. This sounds stupid, but I am really confused on this... I was wondering why we have to write a C++ program with this: #include <iostream> using std::cout; using std::endl;
5
2615
by: wongjoekmeu | last post by:
Dear All, I have written a small program to read in from console a user string. I wanted to be able to read in a string containing of all sorts of characters untill the user press enter. I have to use in my program the scanf function. The program works fine, but there is one exception. When I don't insert any input, but simply press enter, I want actually to pop up asking the user to enter a valid input. But it seems according to my...
11
6763
by: Adrian | last post by:
Is it possible to save a copy of cout the same way you can save a copy of stdout in C (I know C version is portable, but unix portable is good enough for me). I have to use a library which closes stdout on init because its used to mostly in background processes but I need it for an interactive process. Library cant be changed unfortunately. I tried the following but the C++ version doesn't work, I guess because it only shares the...
58
4880
by: Mark Casternoff | last post by:
I'm getting back into C++ after a long hiatus (they didn't have namespaces back then). I know this question is completely subjective, but I'd be interested in hearing which is the "better" style and what the pros and cons are (I'm using cout as example, but it really applies to any similar construct): 1) using std::cout;
0
9975
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9812
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11212
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10799
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10446
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9614
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7154
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5832
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3263
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.