473,698 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't find library for iostream

Hi!
Trying to get a simple cpp program to compile, I'd got the linker
complaining it could'nt find eiter cout nor endl or other object which
belong to iostream. I'd had to use stdiolib to get the program working.
I'd have attached the source code, some of it is Norwegian, but I'd
think it will make sense anyway.

Do anybody have a clue why the library is missing? The code compiled ok
because the .h file is there, but the linker is stopping with the
message "unassigned reference to cout...".

Cincerely,
Sigmund

// #include<iostre am.h>
#include<stdio. h>

static int idcnt; // se T

class T
{
public:
//static int idcnt; // denne liker ikke linkeren
int id;

int number;
T( int n ){
number = n;
id = idcnt++;
printf( "Constructo r kalt %d\n", id );
}

T( const T &t ){
number = t.number;
id = idcnt++;
printf( "Kopierings-constructor: %d\n", id );
}

~T(){
printf( "Destructor kalt: %d\n", id );
}

void setNumber( int n ){
number = n;
}
};

void setNumber( T t, int n );
void setPNumber( T *t, int n );

// finner iostream.h, men ikke det tilhørende bibloteket

void main(){

T t(-1);
// cout << "Constructo r setter number til -1 " << t.number << endl;
printf( "Constructo r setter number til -1: %d\n", t.number );

setNumber( t, 4 );
// cout << "Instans gitt ved referanse endrer ikke instansen ";
// cout << t.number << endl;
printf( "Instans gitt ved referanse endrer ikke instansen: %i\n", t.number );

setPNumber( &t, 4 );
// cout << "Instans gitt med peker endrer instansen: ";
// cout << t.number << endl;
printf( "Instans gitt med peker endrer instansen: %i\n", t.number );

t.setNumber( 6 );
//cout << "Medlemsfunksjo n endrer instansen " << t.number << endl;
printf( "Medlemsfunksjo n endrer instansen %i\n", t.number );
}

void setNumber( T t, int n ){
t.number = n;
printf("Her kalles kopi-constructor for å kopiere instansen\n");
}

void setPNumber( T *t, int n){

t->number = n;
}

Jul 22 '05 #1
2 2205
Sigmund Skjelnes wrote:
Trying to get a simple cpp program to compile, I'd got the linker
complaining it could'nt find eiter cout nor endl or other object which
belong to iostream. I'd had to use stdiolib to get the program working.
I'd have attached the source code, [...]
Please don't post attachments. Copy and paste the code into the message
if you have to send it. It is likely, though, that if it _compiles_, we
cannot help you any more. Linking is not defined by the language itself.
Do anybody have a clue why the library is missing? [...]


Because you didn't tell your compiler where to find the library, maybe?

Ask in a newsgroup that deals with your compiler or with your OS. They
might know more about the compiler options (switches) you need to provide
or the libraries you need to list in the link command line.
<offtopic> Example: often programs on UNIX don't link unless you mention
the math library using the -lm switch</offtopic>

Victor
Jul 22 '05 #2

"Sigmund Skjelnes" <sk******@robin .no> wrote in message
news:41******** @news.broadpark .no...
Hi!
Trying to get a simple cpp program to compile, I'd got the linker
complaining it could'nt find eiter cout nor endl or other object which
belong to iostream. I'd had to use stdiolib to get the program working.
I'd have attached the source code, some of it is Norwegian, but I'd
think it will make sense anyway.

Do anybody have a clue why the library is missing? The code compiled ok
because the .h file is there, but the linker is stopping with the
message "unassigned reference to cout...".

Cincerely,
Sigmund
----------------------------------------------------------------------------
----

// #include<iostre am.h>


The C++ header which declares 'cout' et.al. is <iostream> , with no '.h'
The header which declares 'endl' is <ostream>

All the standard library names (except macros) are in namespace
'std'.

#include <iostream>
using std::cout;

#include <ostream>
using std::endl;

But this doesn't explain why you get a successful compile
but a failed link. (Your compile was successful because
apparently your compiler recognizes the old, pre-standard
C++ without namespaces.)

I'm guessing that perhaps you're running your C++ compiler
in 'C mode'. Double check that.

If you're still stuck, you'll need to consult support resources
for your compiler (web site, phone support, newsgroups for
your compiler, etc.)

-Mike
Jul 22 '05 #3

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

Similar topics

1
2652
by: Rex_chaos | last post by:
Hi all, I am trying to compile a simple source to a library(.a). My code has been seperated into two parts, header file and implementation. // header file NSPWin.hpp #ifndef __TESTLIB_H_ #define __TESTLIB_H_ #include <iostream>
3
4438
by: Prakash Bande | last post by:
Hi, I have bool operator == (xx* obj, const string st). I have declared it as friend of class xx. I am now able to do this: xx ox; string st; if (&ox == st) { } But, when I have a vector<xx*> and use stl find string xyz;
1
2492
by: Dave | last post by:
Hi, I need to use Botan C++ library in my project. But I m having trouble with finding the header file. The botan library and its header files are already installed in /usr/local/lib and /usr/local/include. I got the following error when compiling it in FreeBSD 5.4: make -f Makefile c++ -I/usr/local/include -c auth.cpp -o auth.o auth.cpp: In constructor `Auth::Auth()':
27
2161
by: Pete | last post by:
I'm doing exercise 8-2 from "Accelerated C++" where we're supposed to implement library algorithms, trying to minimize the number of iterator operations. I have two questions so far. First, it took me a while to figure out how to get accumulate() to compile correctly: // begin and begin2 must both be input iterators.
3
1525
by: Allen Maki | last post by:
I am using multiple arrays to make tables of rows and columns. When using C++ I was able to manipulate texts by using cout << setw(3) << .... using directives iomanip.h and iostream.h.
6
3700
by: Tashfeen Bhimdi | last post by:
I'm trying to remove punctuation from a string with the following code: ---------------------------- #include <string> #include <algorithm> #include <cctype> .. using namespace std ..
1
2194
by: mido | last post by:
I am currently trying to compile code which uses old C code with a C++ wrapper. It had compiled on earlier versions of software (within the past two years), but Maya needs an updated version. I think one source of the problems is that the C code relies on old libraries. I tried changing <iostream.hto <iostreambut it introduced a handful of errors in the C code which I am hoping to avoid getting wrapped up in. I get the following...
10
1416
by: spacebebop | last post by:
#include <cstring> #include <iostream> using namespace std; class X { public: X(); X( char * ); ~X();
7
2432
by: Adrian | last post by:
Why does std::strings find search from the begining of the string when pos >= (std::string::npos-3) I cant find anything in the standard that says what find should do if pos==npos in find I tried it on a few platforms (all with gcc unfortunaley) and its seems to be consistent. Adrian
0
8683
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
9031
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...
1
8901
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
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
4371
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...
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.