From: Hiromichi Watari Date: April 3 2011 7:54pm Subject: Re: Problem linking STL::map with mysqld List-Archive: http://lists.mysql.com/internals/38282 Message-Id: <436721.15321.qm@web121517.mail.ne1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Magnus, Thank you for your suggestion, I included the following at the end of table= .h and I got similar and more errors. Looks like I might have to write my own map container (oh nooooooooo !). Hiromichi bool is_simple_order(ORDER *order); /**************************************************************************= ** Used templates ***************************************************************************= */ #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION template class std::map; #endif #endif /* MYSQL_CLIENT */ #endif /* TABLE_INCLUDED */ ---------------------------------------------------------------- [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(mysqld.cc.o): In function `std::map, std:= :allocator > >::operator=3D(std::map, std::allocator > > const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:253: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::operator=3D(std::_Rb_tree, std::_Select1st >, std::les= s, std::allocator > > const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::insert(std::pair = const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:500: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::_M_insert_unique(std::pair const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::insert(std::_Rb_tree_iterator >, std::pair const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:540: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::_M_insert_unique_(std::_Rb_tree_cons= t_iterator >, std::pair const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::erase(int const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:582: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::erase(int const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::erase(std::_Rb_tree_iterator >, std::_Rb_tree_iterator >= )': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:597: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::erase(std::_Rb_tree_iterator >, std::_Rb_tree_iterator >)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::swap(std::map, std::allocator > >&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:616: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::swap(std::_Rb_tree, std::_Select1st >, std::less,= std::allocator > >&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::find(int const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:659: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::find(int const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::find(int const&) const': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:674: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::find(int const&) const' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::count(int const&) const': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:686: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::find(int const&) const' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::equal_range(int const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:755: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::equal_range(int const&)' libsql.a(mysqld.cc.o): In function `std::map, std:= :allocator > >::equal_range(int const&) const': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _map.h:774: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::equal_range(int const&) const' libsql.a(mysqld.cc.o): In function `_Rb_tree': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:602: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_copy(std::_Rb_tree_node > const*, std::_Rb_tree_node >*= )' libsql.a(mysqld.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::clear()': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:726: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_erase(std::_Rb_tree_node >*)' libsql.a(mysqld.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::lower_bound(int const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:745: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_lower_bound(std::_Rb_tree_node >*, std::_Rb_tree_node >= *, int const&)' libsql.a(mysqld.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::lower_bound(int const&) const': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:749: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_lower_bound(std::_Rb_tree_node > const*, std::_Rb_tree_node > const*, int const&) const' libsql.a(mysqld.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::upper_bound(int const&)': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:753: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_upper_bound(std::_Rb_tree_node >*, std::_Rb_tree_node >= *, int const&)' libsql.a(mysqld.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::al= locator > >::upper_bound(int const&) const': /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/stl= _tree.h:757: undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, std::a= llocator > >::_M_upper_bound(std::_Rb_tree_node > const*, std::_Rb_tree_node > const*, int const&) const' libsql.a(sql_base.cc.o): In function `std::_Rb_tree, std::_Select1st >, std::less, std::= allocator > >::~_Rb_tree()': sql_base.cc:(.text._ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIi= ESaIS2_EED2Ev[_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS= 2_EED5Ev]+0x28): undefined reference to `std::_Rb_tree, std::_Select1st >, std::less, st= d::allocator > >::_M_erase(std::_Rb_tree_node >*)' 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 --- On Sun, 4/3/11, Magnus Bl=E5udd wrote: > From: Magnus Bl=E5udd > Subject: Re: Problem linking STL::map with mysqld > To: "Hiromichi Watari" > Cc: internals@stripped > Date: Sunday, April 3, 2011, 1:33 PM > On 2011-04-02 23:57, 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. > > > > > > CXXFLAGS=3D"-DUSE_SYS_STL" > > > > table.h has the following > > > > #include > > . > > . > > . > > std::map=A0 foo; > > > > > > Are there any name conflicts, since table.h is > eventually included in just about every source ? > > I'm not sure if I can use namespace to work around > this problem ? > > >=20 >=20 > Hi Hiromichi, >=20 > the MySQl Server coee is normally compiled with the > compiler flags set=20 > so that you need too explicitly instantiate the templates > you use. >=20 > Instantiate your template with code like >=20 > template std::map; >=20 > at the end ouf your source file. >=20 >=20 > You can search for "template" in sql/ for similar > instantiations. >=20 >=20 > / Magnus Blaudd >=20 >=20 > > > > > > > > > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------- > > . > > . > > . > > . > > . > > [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, > std::_Select1st=A0 > >, std::less, > std::allocator=A0 > >=A0 >::~_Rb_tree()': > > > sql_base.cc:(.text._ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4less= IiESaIS2_EED2Ev[_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESa= IS2_EED5Ev]+0x28): > undefined reference to `std::_Rb_tree std::pair, > std::_Select1st=A0 > >, std::less, > std::allocator=A0 > >=A0 > >::_M_erase(std::_Rb_tree_node int>=A0 >*)' > > libsql.a(sql_insert.cc.o): In function > `std::map, > std::allocator=A0 > >=A0 >::operator=3D(std::map std::less, std::allocator const, int>=A0 >=A0 >=A0 const&)': > > > sql_insert.cc:(.text._ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEaSERKS6_[std:= :map int, std::less, > std::allocator=A0 > >=A0 >::operator=3D(std::map std::less, std::allocator const, int>=A0 >=A0 >=A0 > const&)]+0x20): undefined reference to > `std::_Rb_tree, > std::_Select1st=A0 > >, std::less, > std::allocator=A0 > >=A0 >::operator=3D(std::_Rb_tree std::pair, > std::_Select1st=A0 > >, std::less, > std::allocator=A0 > >=A0 >=A0 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 > > >=20 >