尝试使用mysql ++库编译时,不推荐使用std :: auto_ptr类

时间:2019-02-25 16:37:02

标签: c++ compilation libmysql

我在华硕Tinker Board的C ++程序中尝试使用mysql ++。h时遇到编译问题。

包括如下内容:

#include <mysql++.h>
#include <stdlib.h>

执行的G ++命令就是这个:

g++ -I/usr/include/mysql -I/usr/include/mysql++ -L/usr/lib -lmysqlpp -lmysqlclient mysql.c -o mysql

输出包含以下内容:

In file included from /usr/include/mysql++/sql_buffer.h:31:0,
                 from /usr/include/mysql++/stadapter.h:35,
                 from /usr/include/mysql++/qparms.h:35,
                 from /usr/include/mysql++/query.h:35,
                 from /usr/include/mysql++/mysql++.h:58,
                 from mysql.c:1:
/usr/include/mysql++/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer<T, Destroyer>::RefCountedPointer(T*)’:
/usr/include/mysql++/refcounted.h:104:8: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
   std::auto_ptr<T> exception_guard(counted_);
        ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/include/mysql++/refcounted.h:31,
                 from /usr/include/mysql++/sql_buffer.h:31,
                 from /usr/include/mysql++/stadapter.h:35,
                 from /usr/include/mysql++/qparms.h:35,
                 from /usr/include/mysql++/query.h:35,
                 from /usr/include/mysql++/mysql++.h:58,
                 from mysql.c:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~

我试图通过将“ std :: auto_ptr”更改为“ std :: unique_ptr”来修改文件“ /refcounted.h”,它编译成功,但是在尝试运行程序时出现了“段错误”。 / p>

请帮助,谢谢。

0 个答案:

没有答案