C++ compiling problem

Discussion in 'C++' started by wentaozhou@gmail.com, Jan 14, 2007.

  1. Guest

    Hi all,

    I encounter a problem when compiling in Ubuntu a c++ code wrote
    originally also in linux environment. It seems to be the problem of
    standard template library but I totally don't know how to handle it.
    Could anybody help me out?
    Below please see the error message:

    .......
    block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ca):
    undefined reference to `std::__default_alloc_template<true,
    0>::_S_free_list'
    block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5d8):
    undefined reference to `std::__default_alloc_template<true,
    0>::_S_node_allocator_lock'
    block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ea):
    undefined reference to `std::__default_alloc_template<true,
    0>::_S_node_allocator_lock'
    .../../lembsk/liblembsk.a(block.o): In function `void
    std::_Construct<std::vector<double, std::allocator<double> >,
    std::vector<double, std::allocator<double> > >(std::vector<double,
    std::allocator<double> >*, std::vector<double, std::allocator<double> >
    const&)':
    block.cpp:(.gnu.linkonce.t._ZSt10_ConstructISt6vectorIdSaIdEES2_EvPT_RKT0_+0x40):
    undefined reference to `std::__default_alloc_template<true,
    0>::allocate(unsigned int)'
    collect2: ld returned 1 exit status
    make[2]: *** [lembsk] Error 1
    make[2]: Leaving directory
    `/home/vito/_research_stanford/code/lembsk/Optimized/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory
    `/home/vito/_research_stanford/code/lembsk/Optimized'
    make: *** [all] Error 2


    Thanks so much!

    Vito
    , Jan 14, 2007
    #1
    1. Advertising

  2. Ondra Holub Guest

    napsal:
    > Hi all,
    >
    > I encounter a problem when compiling in Ubuntu a c++ code wrote
    > originally also in linux environment. It seems to be the problem of
    > standard template library but I totally don't know how to handle it.
    > Could anybody help me out?
    > Below please see the error message:
    >
    > ......
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ca):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_free_list'
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5d8):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_node_allocator_lock'
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ea):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_node_allocator_lock'
    > ../../lembsk/liblembsk.a(block.o): In function `void
    > std::_Construct<std::vector<double, std::allocator<double> >,
    > std::vector<double, std::allocator<double> > >(std::vector<double,
    > std::allocator<double> >*, std::vector<double, std::allocator<double> >
    > const&)':
    > block.cpp:(.gnu.linkonce.t._ZSt10_ConstructISt6vectorIdSaIdEES2_EvPT_RKT0_+0x40):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::allocate(unsigned int)'
    > collect2: ld returned 1 exit status
    > make[2]: *** [lembsk] Error 1
    > make[2]: Leaving directory
    > `/home/vito/_research_stanford/code/lembsk/Optimized/src'
    > make[1]: *** [all-recursive] Error 1
    > make[1]: Leaving directory
    > `/home/vito/_research_stanford/code/lembsk/Optimized'
    > make: *** [all] Error 2
    >
    >
    > Thanks so much!
    >
    > Vito


    Hi. Are you linking with g++ or with gcc? C++ code should be compiled
    and linked with g++, because it automaticaly adds to linker standard
    C++ library (in default behaviour).
    Ondra Holub, Jan 14, 2007
    #2
    1. Advertising

  3. wrote:
    > Hi all,
    >
    > I encounter a problem when compiling in Ubuntu a c++ code wrote
    > originally also in linux environment. It seems to be the problem of
    > standard template library but I totally don't know how to handle it.
    > Could anybody help me out?
    > Below please see the error message:
    >
    > ......
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ca):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_free_list'
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5d8):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_node_allocator_lock'
    > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ea):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::_S_node_allocator_lock'
    > ../../lembsk/liblembsk.a(block.o): In function `void
    > std::_Construct<std::vector<double, std::allocator<double> >,
    > std::vector<double, std::allocator<double> > >(std::vector<double,
    > std::allocator<double> >*, std::vector<double, std::allocator<double> >
    > const&)':
    > block.cpp:(.gnu.linkonce.t._ZSt10_ConstructISt6vectorIdSaIdEES2_EvPT_RKT0_+0x40):
    > undefined reference to `std::__default_alloc_template<true,
    > 0>::allocate(unsigned int)'
    > collect2: ld returned 1 exit status
    > make[2]: *** [lembsk] Error 1
    > make[2]: Leaving directory
    > `/home/vito/_research_stanford/code/lembsk/Optimized/src'
    > make[1]: *** [all-recursive] Error 1
    > make[1]: Leaving directory
    > `/home/vito/_research_stanford/code/lembsk/Optimized'
    > make: *** [all] Error 2
    >
    >
    > Thanks so much!


    What does "g++ --version" say?

    - J.
    Jacek Dziedzic, Jan 14, 2007
    #3
  4. vito Guest

    I linked with g++.
    Ondra Holub wrote:
    > napsal:
    > > Hi all,
    > >
    > > I encounter a problem when compiling in Ubuntu a c++ code wrote
    > > originally also in linux environment. It seems to be the problem of
    > > standard template library but I totally don't know how to handle it.
    > > Could anybody help me out?
    > > Below please see the error message:
    > >
    > > ......
    > > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ca):
    > > undefined reference to `std::__default_alloc_template<true,
    > > 0>::_S_free_list'
    > > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5d8):
    > > undefined reference to `std::__default_alloc_template<true,
    > > 0>::_S_node_allocator_lock'
    > > block.cpp:(.gnu.linkonce.t._ZN6lembsk5FieldISt6vectorINS_5PointESaIS2_EEE7setsizeEiiii+0x5ea):
    > > undefined reference to `std::__default_alloc_template<true,
    > > 0>::_S_node_allocator_lock'
    > > ../../lembsk/liblembsk.a(block.o): In function `void
    > > std::_Construct<std::vector<double, std::allocator<double> >,
    > > std::vector<double, std::allocator<double> > >(std::vector<double,
    > > std::allocator<double> >*, std::vector<double, std::allocator<double> >
    > > const&)':
    > > block.cpp:(.gnu.linkonce.t._ZSt10_ConstructISt6vectorIdSaIdEES2_EvPT_RKT0_+0x40):
    > > undefined reference to `std::__default_alloc_template<true,
    > > 0>::allocate(unsigned int)'
    > > collect2: ld returned 1 exit status
    > > make[2]: *** [lembsk] Error 1
    > > make[2]: Leaving directory
    > > `/home/vito/_research_stanford/code/lembsk/Optimized/src'
    > > make[1]: *** [all-recursive] Error 1
    > > make[1]: Leaving directory
    > > `/home/vito/_research_stanford/code/lembsk/Optimized'
    > > make: *** [all] Error 2
    > >
    > >
    > > Thanks so much!
    > >
    > > Vito

    >
    > Hi. Are you linking with g++ or with gcc? C++ code should be compiled
    > and linked with g++, because it automaticaly adds to linker standard
    > C++ library (in default behaviour).
    vito, Jan 18, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. marko sarunac
    Replies:
    0
    Views:
    583
    marko sarunac
    Nov 17, 2003
  2. David Berman

    Problem compiling ASP.NET application

    David Berman, Jan 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    366
    David Berman
    Jan 28, 2004
  3. Garrett Cooper
    Replies:
    0
    Views:
    554
    Garrett Cooper
    Feb 24, 2009
  4. Garrett Cooper
    Replies:
    0
    Views:
    495
    Garrett Cooper
    Feb 24, 2009
  5. Lon Baker
    Replies:
    1
    Views:
    221
    Csaba Henk
    Mar 21, 2005
Loading...

Share This Page