473,326 Members | 2,680 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,326 software developers and data experts.

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<iostream.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( "Constructor 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 << "Constructor setter number til -1 " << t.number << endl;
printf( "Constructor 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 << "Medlemsfunksjon endrer instansen " << t.number << endl;
printf( "Medlemsfunksjon 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 2185
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<iostream.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
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_...
3
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*>...
1
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...
27
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,...
3
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
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
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...
10
by: spacebebop | last post by:
#include <cstring> #include <iostream> using namespace std; class X { public: X(); X( char * ); ~X();
7
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.