如何克服;对“U M U insert”U aux()的未定义引用;? 我编译了一些C++程序,我使用了PurthBeBuffe函数。最后我得到了这个错误: /usr/include/c++/4.4/bits/stl_vector.h:741: undefined reference to `std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::**_M_insert_aux**(__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

如何克服;对“U M U insert”U aux()的未定义引用;? 我编译了一些C++程序,我使用了PurthBeBuffe函数。最后我得到了这个错误: /usr/include/c++/4.4/bits/stl_vector.h:741: undefined reference to `std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::**_M_insert_aux**(__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)',c++,stl,C++,Stl,我用以下(main.cpp)重现了此编译器错误: 如果未指定-fno implicit templates选项,它将编译 检查是否指定了编译器标志-fno implicit templates,如果可能,将其删除 要使用-fno隐式模板构建,我将源代码更改为: #include <vector> #include <string> //class template std::vector<std::string>; TYPO here: 'class' &a

我用以下(
main.cpp
)重现了此编译器错误:

如果未指定
-fno implicit templates
选项,它将编译

检查是否指定了编译器标志
-fno implicit templates
,如果可能,将其删除

要使用
-fno隐式模板构建,我将源代码更改为:

#include <vector>
#include <string>

//class template std::vector<std::string>; TYPO here: 'class' & 'template' wrong order 
template class std::vector<std::string>;

int main()
{
    std::vector<std::string> v;
    v.push_back(std::string("test"));
    return 0;
}
然后我再次运行了
make
,它被编译并成功链接。
注意:我使用
-fno隐式模板编译:除了对“sql\u parse.cc”所做的更改之外,我没有对mysql发行版做任何其他更改。

您可以发布生成此版本的代码吗?对于(table=lex->query\u tables;table=table->next\u global){string table\u db=table->db;table\u db+=“:”;table_db=table_db+table->table_name;current.tables.push_back(table_db);DBUG_PRINT(“Dip”,(%s:%s,%s,table->db,table->table->table->table->name,table->alias))}我正在MySQL中嵌入一些代码。请添加
current.tables
的声明。您需要发布一个完整的、最少的代码示例来重现这个错误,以及您如何编译代码。错误肯定不在STL头中,而是在您自己的代码(或编译命令)中。您当前的问题没有必要的详细信息来帮助您。我这样做了,但不起作用…我从配置文件中删除了-fno隐式模板..并添加了该行(class template std::vector;)但不起作用…请提供任何其他建议…如果指定了
-fno隐式模板
,您只需要添加该行。您是否运行了
make distclean
或类似程序来删除所有以前编译的对象?是的,先生,我清理了所有以前的对象…现在我清除了该行并删除了-fno隐式模板,但仍然会出现错误..当您运行
configure
然后运行
make
时,生成过程中显示的编译器命令中是否绝对不存在
-fno implicit templates
选项?是的,生成过程中不存在此命令…我已在“configure.am”文件中删除了该命令
#include <vector>
#include <string>

int main()
{
    std::vector<std::string> v;
    v.push_back(std::string("test"));
    return 0;
}
g++ -fno-implicit-templates main.cpp -o main
#include <vector>
#include <string>

//class template std::vector<std::string>; TYPO here: 'class' & 'template' wrong order 
template class std::vector<std::string>;

int main()
{
    std::vector<std::string> v;
    v.push_back(std::string("test"));
    return 0;
}
// Added these include directives before any other.
#include <vector>
#include <string>

// At the end of include directives added this explicit template
// instantiation.
template class std::vector<std::string>;

// Added the following lines into a random function.
std::vector<std::string> v;
v.push_back(std::string("1"));