linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gcc/g++ fails to compile
@ 2008-08-02 10:09 Phil C
  0 siblings, 0 replies; 4+ messages in thread
From: Phil C @ 2008-08-02 10:09 UTC (permalink / raw)
  To: C Programming Mailing List



Every
time I try and complie with g++ it fails, even on the simplest of jobs.
"hello world" even failed to compile. I don't have the error messages
handy at the moment, but I remember them being something about improper
function calling (? maybe). I refrenced the standard that the version I
use uses (Version 4.3) and couldn't find any issues with the codeing
either. Any ideas? Is it possible that gcc/g++ itself is broken and
needs a fresh compile?

If it's necessary to have the error output I will post that as well.

Thanks

 - Phil C



      


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc/g++ fails to compile
@ 2008-08-03  0:36 Phil C
  2008-08-03  3:31 ` Glynn Clements
  2008-08-03  9:52 ` Kristof Provost
  0 siblings, 2 replies; 4+ messages in thread
From: Phil C @ 2008-08-03  0:36 UTC (permalink / raw)
  To: Steve Graegert; +Cc: C Programming Mailing List

>It is hard to tell what the problem is without sample code and the exact error message along with some details >about your system configuration.


>Regards

 >       \Steve

Sorry for the lack of information I hope this makes the situation more clear. I'm using Ubuntu Linux 8.04 and every current stable patch kernel wise. GCC is version 4.3 Remaining info is as follows.

//Sample Code

#include<iostream>
using namespace std;

int main() {
    cout <<"Hello World";
    return 0;
}

//Error message copied from terminal

/tmp/ccERz0tv.o:
In function `std::__verify_grouping(char const*, unsigned int,
std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)':
test.cpp:(.text+0xe):
undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::size()
const'
test.cpp:(.text+0x59): undefined reference to
`std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::operator[](unsigned int) const'
test.cpp:(.text+0x97):
undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>::operator[](unsigned int) const'
test.cpp:(.text+0xdf):
undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>::operator[](unsigned int) const'
/tmp/ccERz0tv.o: In function `main':
test.cpp:(.text+0x128): undefined reference to `std::cout'
test.cpp:(.text+0x12d):
undefined reference to `std::basic_ostream<char,
std::char_traits<char> >& std::operator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccERz0tv.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x15d): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccERz0tv.o: In function `__tcf_0':
test.cpp:(.text+0x1aa): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccERz0tv.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

 - Phil C


      


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc/g++ fails to compile
  2008-08-03  0:36 Phil C
@ 2008-08-03  3:31 ` Glynn Clements
  2008-08-03  9:52 ` Kristof Provost
  1 sibling, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2008-08-03  3:31 UTC (permalink / raw)
  To: Phil C; +Cc: Steve Graegert, C Programming Mailing List


Phil C wrote:

> > It is hard to tell what the problem is without sample code and the
> > exact error message along with some details about your system
> > configuration.
> 
> 
> >Regards
> 
>  >       \Steve
> 
> Sorry for the lack of information I hope this makes the situation more
> clear. I'm using Ubuntu Linux 8.04 and every current stable patch
> kernel wise. GCC is version 4.3 Remaining info is as follows.
> 
> //Sample Code
> 
> #include<iostream>
> using namespace std;
> 
> int main() {
>     cout <<"Hello World";
>     return 0;
> }
> 
> //Error message copied from terminal
> 
> /tmp/ccERz0tv.o:
> In function `std::__verify_grouping(char const*, unsigned int,
> std::basic_string<char, std::char_traits<char>,
> std::allocator<char> > const&)':
> test.cpp:(.text+0xe):
> undefined reference to `std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >::size()
> const'

[more "undefined reference" errors snipped]

For linking, you need to either use "g++" (rather than "gcc"), or
explicitly link against the C++ library with "-lstdc++". IOW:

	g++ test.cc
or:
	gcc test.cc -lstdc++

-- 
Glynn Clements <glynn@gclements.plus.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc/g++ fails to compile
  2008-08-03  0:36 Phil C
  2008-08-03  3:31 ` Glynn Clements
@ 2008-08-03  9:52 ` Kristof Provost
  1 sibling, 0 replies; 4+ messages in thread
From: Kristof Provost @ 2008-08-03  9:52 UTC (permalink / raw)
  To: Phil C; +Cc: Steve Graegert, C Programming Mailing List

On 2008-08-02 17:36:07 (-0700), Phil C <hpypenguin@yahoo.com> wrote:
> >It is hard to tell what the problem is without sample code and the exact error message along with some details >about your system configuration.
> 
> 
> >Regards
> 
>  >       \Steve
> 
> Sorry for the lack of information I hope this makes the situation more clear. I'm using Ubuntu Linux 8.04 and every current stable patch kernel wise. GCC is version 4.3 Remaining info is as follows.
> 
> //Sample Code
> 
> #include<iostream>
> using namespace std;
> 
> int main() {
>     cout <<"Hello World";
>     return 0;
> }
> 
> //Error message copied from terminal
> 
> /tmp/ccERz0tv.o:
> In function `std::__verify_grouping(char const*, unsigned int,
> std::basic_string<char, std::char_traits<char>,
> std::allocator<char> > const&)':
> test.cpp:(.text+0xe):
> undefined reference to `std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >::size()
> const'
> test.cpp:(.text+0x59): undefined reference to
> `std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >::operator[](unsigned int) const'
> test.cpp:(.text+0x97):
> undefined reference to `std::basic_string<char,
> std::char_traits<char>, std::allocator<char>
> >::operator[](unsigned int) const'
> test.cpp:(.text+0xdf):
> undefined reference to `std::basic_string<char,
> std::char_traits<char>, std::allocator<char>
> >::operator[](unsigned int) const'
> /tmp/ccERz0tv.o: In function `main':
> test.cpp:(.text+0x128): undefined reference to `std::cout'
> test.cpp:(.text+0x12d):
> undefined reference to `std::basic_ostream<char,
> std::char_traits<char> >& std::operator<<
> <std::char_traits<char> >(std::basic_ostream<char,
> std::char_traits<char> >&, char const*)'
> /tmp/ccERz0tv.o: In function `__static_initialization_and_destruction_0(int, int)':
> test.cpp:(.text+0x15d): undefined reference to `std::ios_base::Init::Init()'
> /tmp/ccERz0tv.o: In function `__tcf_0':
> test.cpp:(.text+0x1aa): undefined reference to `std::ios_base::Init::~Init()'
> /tmp/ccERz0tv.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
> collect2: ld returned 1 exit status
> 
Try 'sudo apt-get install libstdc++6'.
If that doesn't work please provide the exact command you used to
compile.

Kristof

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-03  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-02 10:09 gcc/g++ fails to compile Phil C
  -- strict thread matches above, loose matches on Subject: below --
2008-08-03  0:36 Phil C
2008-08-03  3:31 ` Glynn Clements
2008-08-03  9:52 ` Kristof Provost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).