C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

can't find library for iostream

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Victor Bazarov
Guest





PostPosted: Mon Aug 30, 2004 2:54 pm    Post subject: Re: can't find library for iostream Reply with quote



Sigmund Skjelnes wrote:
Quote:
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.

Quote:
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

Back to top
Mike Wahler
Guest





PostPosted: Mon Aug 30, 2004 2:58 pm    Post subject: Re: can't find library for iostream Reply with quote




"Sigmund Skjelnes" <skjelnes (AT) robin (DOT) no> wrote

Quote:
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



----------------------------------------------------------------------------
----


Quote:
// #include<iostream.h

The C++ header which declares 'cout' et.al. is 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



Back to top
Sigmund Skjelnes
Guest





PostPosted: Mon Aug 30, 2004 4:50 pm    Post subject: can't find library for iostream Reply with quote



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 %dn", id );
}

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

~T(){
printf( "Destructor kalt: %dn", 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: %dn", 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: %in", t.number );

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

t.setNumber( 6 );
//cout << "Medlemsfunksjon endrer instansen " << t.number << endl;
printf( "Medlemsfunksjon endrer instansen %in", t.number );
}

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

void setPNumber( T *t, int n){

t->number = n;
}

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.