List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:April 4 2011 3:03pm
Subject:Re: Problem linking STL::map with mysqld
View as plain text  
Hi, Hiromichi!

For historical reasons MySQL uses -fno-implicit-templates.
Either disable that or instantiate all your templates explicitly.

To disable: remove it from configure.cmake.

To instantiate explicitly: look at the error message, it says, for
example

...  undefined reference to `std::_Rb_tree<int, std::pair<int const, int>,
std::_Select1st<std::pair<int const, int> >, std::less<int>,
std::allocator<std::pair<int const, int> >
>::_M_erase(std::_Rb_tree_node<std::pair<int const, int> >*)'

which means, you need to put in your source, somewhere:

#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace std {
template _Rb_tree<int, std::pair<int const, int>,
std::_Select1st<std::pair<int const, int> >, std::less<int>,
std::allocator<std::pair<int const, int> >
>::_M_erase(std::_Rb_tree_node<std::pair<int const, int> >*);
}
#endif

and repeat for all undefined symbols.

On Apr 02, Hiromichi Watari wrote:
> Hi,
> I'm trying to use STL container "map" with MySQL server but I'm
> getting the following link error at the very end.
> 
> [100%] Building CXX object sql/CMakeFiles/sql.dir/sql_yacc.cc.o
> [100%] Building CXX object sql/CMakeFiles/sql.dir/sql_builtin.cc.o
> Linking CXX static library libsql.a
> [100%] Built target sql
> [100%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
> Linking CXX executable mysqld
> libsql.a(sql_base.cc.o): In function `std::_Rb_tree<int, std::pair<int const,
> int>, std::_Select1st<std::pair<int const, int> >, std::less<int>,
> std::allocator<std::pair<int const, int> > >::~_Rb_tree()':
>
> sql_base.cc:(.text._ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EED2Ev[_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EED5Ev]+0x28):
> undefined reference to `std::_Rb_tree<int, std::pair<int const, int>,
> std::_Select1st<std::pair<int const, int> >, std::less<int>,
> std::allocator<std::pair<int const, int> >
> >::_M_erase(std::_Rb_tree_node<std::pair<int const, int> >*)'
> libsql.a(sql_insert.cc.o): In function `std::map<int, int, std::less<int>,
> std::allocator<std::pair<int const, int> > >::operator=(std::map<int,
> int, std::less<int>, std::allocator<std::pair<int const, int> > >
> const&)':
> sql_insert.cc:(.text._ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEaSERKS6_[std::map<int,
> int, std::less<int>, std::allocator<std::pair<int const, int> >
> >::operator=(std::map<int, int, std::less<int>,
> std::allocator<std::pair<int const, int> > > const&)]+0x20): undefined
> reference to `std::_Rb_tree<int, std::pair<int const, int>,
> std::_Select1st<std::pair<int const, int> >, std::less<int>,
> std::allocator<std::pair<int const, int> >
> >::operator=(std::_Rb_tree<int, std::pair<int const, int>,
> std::_Select1st<std::pair<int const, int> >, std::less<int>,
> std::allocator<std::pair<int const, int> > > const&)'
> collect2: ld returned 1 exit status
> make[2]: *** [sql/mysqld] Error 1
> make[1]: *** [sql/CMakeFiles/mysqld.dir/all] Error 2
> make: *** [all] Error 2
> 
Regards,
Sergei
Thread
Unable to download the source tree using bazaarKarthik Gurukuntala25 Feb
  • Re: Unable to download the source tree using bazaarGuilhem Bichot25 Feb
    • Re: Unable to download the source tree using bazaarKarthik Gurukuntala26 Feb
      • Re: Unable to download the source tree using bazaarGuilhem Bichot26 Feb
    • bazaar/launchpad down ?Hiromichi Watari10 Mar
      • Re: bazaar/launchpad down ?Lenz Grimmer15 Mar
        • Re: bazaar/launchpad down ?Hiromichi Watari15 Mar
          • Re: bazaar/launchpad down ?Lenz Grimmer15 Mar
            • Re: bazaar/launchpad down ?Hiromichi Watari18 Mar
              • doxygen documentation missing ?Hiromichi Watari10 Jan
              • Problem linking STL::map with mysqldHiromichi Watari2 Apr
                • Re: Problem linking STL::map with mysqldMagnus BlĂ„udd3 Apr
                  • Re: Problem linking STL::map with mysqldHiromichi Watari3 Apr
                    • Re: Problem linking STL::map with mysqldTor Didriksen4 Apr
                      • Re: Problem linking STL::map with mysqldHiromichi Watari4 Apr
                        • Re: Problem linking STL::map with mysqldTor Didriksen4 Apr
                          • Re: Problem linking STL::map with mysqldHiromichi Watari5 Apr
                • Re: Problem linking STL::map with mysqldSergei Golubchik4 Apr