C++ c++;sqlite3\u prepare\u v2不工作

C++ c++;sqlite3\u prepare\u v2不工作,c++,dll,sqlite,C++,Dll,Sqlite,这是我的第一篇帖子,所以如果我忘记添加一些信息,或者我的英语错误,请原谅 我用C++代码工作:块(13.12),用DILITE3函数制作DLL,使用明码工具链。(windows 7) 我正在使用sqlite3\u exec函数,但我想更改为sqlite3\u prepare\u v2,sqlite\u bind,sqlite3\u step,等等,因为我认为返回参数很容易。 然而,在调用另一个C++程序中的新函数之后,它给了我这个错误: Nombre del evento de probl

这是我的第一篇帖子,所以如果我忘记添加一些信息,或者我的英语错误,请原谅

我用C++代码工作:块(13.12),用DILITE3函数制作DLL,使用明码工具链。(windows 7)

我正在使用
sqlite3\u exec
函数,但我想更改为
sqlite3\u prepare\u v2
sqlite\u bind
sqlite3\u step
,等等,因为我认为返回参数很容易。 然而,在调用另一个C++程序中的新函数之后,它给了我这个错误:

   Nombre del evento de problema:   APPCRASH
   Nombre de la aplicación: SQL_try.exe
   Versión de la aplicación:    0.0.0.0
   Marca de tiempo de la aplicación:    5594a5af
   Nombre del módulo con errores:   sqlite3.dll
   Versión del módulo con errores:  3.8.10.2
   Marca de tiempo del módulo con errores:  555cd28a
   Código de excepción: c0000005
   Desplazamiento de excepción: 0001ee21
   Versión del sistema operativo:   6.1.7601.2.1.0.768.3
   Id. de configuración regional:   3082
   Información adicional 1: 0a9e
   Información adicional 2: 0a9e372d3b4ad19135b953a78882e789`
   Información adicional 3: 0a9e
   Información adicional 4: 0a9e372d3b4ad19135b953a78882e789
我不能很容易地清除它,因为我不习惯代码:block,而且我正在从DLL调用函数

这是我正在使用的函数,我从另一篇文章中得到:[

我正在使用以下命令调用DLL函数:

typedef string (*Myfunc5) (sqlite3*,int);
Myfunc5 mifunc5(0);
string String;
mifunc5=(Myfunc5)GetProcAddress(  histDLL,"readFromDB");
String=(mifunc5)(db,1);
我不认为问题在于数据库没有加载,因为其他函数都可以工作,我试图注释所有函数,除了
sqlite3\u prepare\u v2
sqlite3\u finalize
函数,这两个函数都不能工作

编辑:

DLLSQL.h:

#include "sqlite3.h"
#include <stdio.h>
#include <string>
#include <stdexcept>      // std::invalid_argument

/*  To use this exported function of dll, include this header
 *  in your project.
 */


    #define DLL_EXPORT __declspec(dllexport)
    using std::string;
    using std::exception;


            #ifdef __cplusplus
        extern "C"
        {
        #endif


        //void DLL_EXPORT SomeFunction(const LPCSTR sometext);





               int DLL_EXPORT CreateDatabase(sqlite3** db,string dbname);
               int DLL_EXPORT ejemplo(char db_err);
               int DLL_EXPORT CreateTable(sqlite3* db, string tbname,char * db_err);
               int DLL_EXPORT fill(sqlite3* db, string tbname);
              void DLL_EXPORT display(sqlite3* db, string tbname);
              void DLL_EXPORT jokersql(sqlite3* db, string sql);
              int DLL_EXPORT row(sqlite3* db, string tbname,string col,string id,int (*callback)(void*,int,char**,char**),void *answer, char **argv);
              int DLL_EXPORT n_row(sqlite3* db, string tbname,int (*callback)(void*,int,char**,char**),void *answer);
                string DLL_EXPORT readFromDB(sqlite3* db, int id);


        #ifdef __cplusplus
        }
        #endif
#包括“sqlite3.h”
#包括
#包括
#include//std::无效的_参数
/*要使用dll的此导出函数,请包含此标头
*在你的项目中。
*/
#定义DLL\u导出\u declspec(dllexport)
使用std::string;
使用std::exception;
#ifdef_uucplusplus
外部“C”
{
#恩迪夫
//void DLL_EXPORT SomeFunction(const LPCSTR sometext);
int DLL_导出CreateDatabase(sqlite3**db,字符串dbname);
int DLL_EXPORT eJMPO(char db_err);
int DLL_EXPORT CreateTable(sqlite3*db,字符串tbname,char*db_err);
int DLL_导出填充(sqlite3*db,字符串tbname);
无效DLL_导出显示(sqlite3*db,字符串tbname);
void DLL_EXPORT jokersql(sqlite3*db,字符串sql);
int DLL_导出行(sqlite3*db,字符串tbname,字符串col,字符串id,int(*回调)(void*,int,char**,char**),void*应答,char**argv);
int DLL_导出n_行(sqlite3*db,字符串tbname,int(*回调)(void*,int,char**,char**),void*应答);
字符串DLL_EXPORT readFromDB(sqlite3*db,int-id);
#ifdef_uucplusplus
}
#恩迪夫

您的代码作为一个正常的可执行文件为我工作,可能与您在动态加载的DLL中调用它的方式有关。您是将sqlite链接为DLL还是.lib?我将其链接为DLL sqlite3.DLL。另一个要检查的是,您也将其链接为标准运行时库DLL,否则您可能会在DLL之间传递std::字符串时遇到问题。不知道如何在代码块中执行此操作。否则,如果无法调试代码,请在代码中放入跟踪消息,以查看出错的地方。显示
DLL\u EXPORT
Myfunc5
的精确定义。显示
DLL\u EXPORT
的精确定义。您的代码对我来说很正常可执行文件,可能与您在动态加载的DLL中调用它的方式有关。您是将sqlite链接为DLL还是.lib?我将其链接为DLL sqlite3.DLL。另一件需要检查的事情是,您也是将其链接为标准运行库DLL,否则在DLL之间传递std::字符串时可能会遇到问题。不确定如何在代码块中执行此操作。否则,如果无法调试代码,请将跟踪消息放入代码中,以查看错误所在。显示
DLL\u EXPORT
Myfunc5
的准确定义。显示
DLL\u EXPORT
的准确定义。
#include "sqlite3.h"
#include <stdio.h>
#include <string>
#include <stdexcept>      // std::invalid_argument

/*  To use this exported function of dll, include this header
 *  in your project.
 */


    #define DLL_EXPORT __declspec(dllexport)
    using std::string;
    using std::exception;


            #ifdef __cplusplus
        extern "C"
        {
        #endif


        //void DLL_EXPORT SomeFunction(const LPCSTR sometext);





               int DLL_EXPORT CreateDatabase(sqlite3** db,string dbname);
               int DLL_EXPORT ejemplo(char db_err);
               int DLL_EXPORT CreateTable(sqlite3* db, string tbname,char * db_err);
               int DLL_EXPORT fill(sqlite3* db, string tbname);
              void DLL_EXPORT display(sqlite3* db, string tbname);
              void DLL_EXPORT jokersql(sqlite3* db, string sql);
              int DLL_EXPORT row(sqlite3* db, string tbname,string col,string id,int (*callback)(void*,int,char**,char**),void *answer, char **argv);
              int DLL_EXPORT n_row(sqlite3* db, string tbname,int (*callback)(void*,int,char**,char**),void *answer);
                string DLL_EXPORT readFromDB(sqlite3* db, int id);


        #ifdef __cplusplus
        }
        #endif