public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC and C++11...no friends?
@ 2014-02-02 16:05 Kevin Ingwersen
  2014-02-02 16:13 ` niXman
  2014-02-03  6:59 ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Ingwersen @ 2014-02-02 16:05 UTC (permalink / raw)
  To: gcc-help

Hey!

I just wanted to try out lambdas and picked up an example from the internet:

#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
 
int main() {

    std::vector<int> c { 1,2,3,4,5,6,7 };
    int x = 5;
    c.erase(std::remove_if(c.begin(), c.end(), [x](int n) { return n < x; } ), c.end());
 
    std::cout << "c: ";
    for (auto i: c) {
        std::cout << i << ' ';
    }
    std::cout << '\n';
 
    std::function<int (int)> func = [](int i) { return i+4; };
    std::cout << "func: " << func(6) << '\n'; 
}

Then, I went to compile this:

	gcc test.cpp -o test -std=c++11

The result:

/tmp/cc4Rcd5b.o: In function `main':
test.cpp:(.text+0xdf): undefined reference to `std::cout'
test.cpp:(.text+0xe4): 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*)'
test.cpp:(.text+0x132): undefined reference to `std::cout'
test.cpp:(.text+0x137): undefined reference to `std::ostream::operator<<(int)'
test.cpp:(.text+0x144): 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)'
test.cpp:(.text+0x17a): undefined reference to `std::cout'
test.cpp:(.text+0x17f): 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)'
test.cpp:(.text+0x1b7): undefined reference to `std::cout'
test.cpp:(.text+0x1bc): 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*)'
test.cpp:(.text+0x1c6): undefined reference to `std::ostream::operator<<(int)'
test.cpp:(.text+0x1d3): 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)'
/tmp/cc4Rcd5b.o: In function `std::_Function_base::_Base_manager<main::{lambda(int)#2}>::_M_clone(std::_Any_data&, std::_Function_base::_Base_manager<main::{lambda(int)#2}> const&, std::integral_constant<bool, false>)':
test.cpp:(.text+0x7a3): undefined reference to `operator new(unsigned long)'
/tmp/cc4Rcd5b.o: In function `std::_Function_base::_Base_manager<main::{lambda(int)#2}>::_M_destroy(std::_Any_data&, std::integral_constant<bool, false>)':
test.cpp:(.text+0x7df): undefined reference to `operator delete(void*)'
/tmp/cc4Rcd5b.o: In function `std::_Function_base::_Base_manager<main::{lambda(int)#2}>::_M_init_functor(std::_Any_data&, {lambda(int)#2}&&, std::integral_constant<bool, false>)':
test.cpp:(.text+0x808): undefined reference to `operator new(unsigned long)'
/tmp/cc4Rcd5b.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x863): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x872): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc4Rcd5b.o:(.rodata+0x30): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/tmp/cc4Rcd5b.o: In function `std::function<int (int)>::operator()(int) const':
test.cpp:(.text._ZNKSt8functionIFiiEEclEi[_ZNKSt8functionIFiiEEclEi]+0x21): undefined reference to `std::__throw_bad_function_call()'
/tmp/cc4Rcd5b.o: In function `__gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim[_ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim]+0x1c): undefined reference to `operator delete(void*)'
/tmp/cc4Rcd5b.o: In function `__gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x2c): undefined reference to `std::__throw_bad_alloc()'
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv]+0x3c): undefined reference to `operator new(unsigned long)'
/tmp/cc4Rcd5b.o:(.eh_frame+0x12b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status

Why isn’t this working? :o

Kind regards, Ingwie

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

* Re: GCC and C++11...no friends?
  2014-02-02 16:05 GCC and C++11...no friends? Kevin Ingwersen
@ 2014-02-02 16:13 ` niXman
  2014-02-02 16:31   ` Kevin Ingwersen
  2014-02-03  6:59 ` Jonathan Wakely
  1 sibling, 1 reply; 4+ messages in thread
From: niXman @ 2014-02-02 16:13 UTC (permalink / raw)
  To: Kevin Ingwersen, gcc-help

Kevin Ingwersen 2014-02-02 20:05:
> Then, I went to compile this:
> 	gcc test.cpp -o test -std=c++11

g++ test.cpp -o test -std=c++11


-- 
Regards, niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingw-w64/
___________________________________________________
Another online IDE: http://liveworkspace.org/

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

* Re: GCC and C++11...no friends?
  2014-02-02 16:13 ` niXman
@ 2014-02-02 16:31   ` Kevin Ingwersen
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Ingwersen @ 2014-02-02 16:31 UTC (permalink / raw)
  To: niXman; +Cc: gcc-help

… just, duh. XD
Thanks. ^.^
Am So. Feb. 02 2014 17:13:40 schrieb niXman:

> Kevin Ingwersen 2014-02-02 20:05:
>> Then, I went to compile this:
>> 	gcc test.cpp -o test -std=c++11
> 
> g++ test.cpp -o test -std=c++11



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

* Re: GCC and C++11...no friends?
  2014-02-02 16:05 GCC and C++11...no friends? Kevin Ingwersen
  2014-02-02 16:13 ` niXman
@ 2014-02-03  6:59 ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2014-02-03  6:59 UTC (permalink / raw)
  To: Kevin Ingwersen; +Cc: gcc-help

On 2 February 2014 16:05, Kevin Ingwersen wrote:
>
> Why isn’t this working? :o

http://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html

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

end of thread, other threads:[~2014-02-03  6:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-02 16:05 GCC and C++11...no friends? Kevin Ingwersen
2014-02-02 16:13 ` niXman
2014-02-02 16:31   ` Kevin Ingwersen
2014-02-03  6:59 ` Jonathan Wakely

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 read-only IMAP folder(s) and NNTP newsgroup(s).