Re: gcc/g++ fails to compile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux