Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [Q] g++ header files
- To: tlug@example.com
- Subject: Re: [Q] g++ header files
- From: turnbull@example.com (Stephen J. Turnbull)
- Date: Wed, 12 Jul 95 13:06 JST
- In-Reply-To: <Pine.HPP.3.91.950710080425.2285A-100000@example.com> (message from Craig Oda on Mon, 10 Jul 1995 08:15:39 +0900 (JST))
- Reply-To: tlug@example.com
- Sender: owner-tlug@example.com
From: Craig Oda <craig@example.com> Hi, I thought I would get our renewed discussion going with a question on g++ I usually use standard c, but I went to the U.S. and bought a book on c++ and tried to go through the first example "hello world" program to make sure the compiler was working. I am having a little trouble: cow:~/practice/c/cpp% g++ -I/usr/include/g++ hello.cc /tmp/cca001071.o(.text+0x1e): undefined reference to `cout' /tmp/cca001071.o(.text+0x23): undefined reference to `ostream::operator<<(char const *)' This is a standard G++ gotcha. For efficiency reasons, the stream operators are implemented *inline*. That is, the machine code is substituted directly into the object file, and you save the overhead of saving registers, a "call" instruction, the "ret" instruction, and restoring registers. When you consider that many stream operations can be implemented in *two* assembly instructions (move from memory to register, advance buffer pointer), you can see that this is a BigWin. The "gotcha" is that G++ only performs correctly under optimization. So you must compile with "g++ -O2 ...". You may also run into a problem with not having the stream library, you may need to add "-liostream" or "-lgpp" or something like that. However, I think that "g++ ..." should do this automatically. Steve
- References:
- [Q] g++ header files
- From: Craig Oda <craig@example.com>
Home | Main Index | Thread Index
- Prev by Date: [Q] g++ header files
- Next by Date: TLUG Meeting
- Prev by thread: [Q] g++ header files
- Next by thread: TLUG Meeting
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links