DLL文件中的SQLite3函数导致外部未解析

时间:2014-12-02 14:24:37

标签: c++ visual-studio dll sqlite

我在Visual Studio 2008中创建一个DLL,需要使用SQLite3。我已将文件sqlite3.h包含在here中。现在我的文件只有一个函数,只需要一个参数,即数据库名称,然后打开它。我的文件如下:

DBOPEN.H

#include <string>
using namespace std;
__declspec(dllexport) bool OpenDatabase(std::string);

DBOPEN.CPP

#include "dbopen.h"
#include "sqlite3.h"

bool OpenDatabase(std::string name)
{
  sqlite3 *database;
  int isOpen = sqlite3_open(name.c_str(), &database);
}

值得注意的是我之前从未编写过DLL,而且我的格式基于我在各种来源的网上找到的内容。但是,当我尝试构建它时,我收到此错误:

1>dbopen.obj : error LNK2019: unresolved external symbol _sqlite3_open referenced in function "bool __cdecl OpenDatabase(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?OpenDatabase@@YA_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>C:\Users\me\Documents\Visual Studio 2008\Projects\dbopen\Debug\dbopen.dll : fatal error LNK1120: 1 unresolved externals

老实说,我真的不确定如何解决这个问题。我尝试过切换各种内容,更改函数定义等,但sqlite3_open不断导致错误。我注意到如果我尝试使用其他sqlite3函数,它们都会给出相同的错误,但是sqlite3对象定义有效。有谁知道如何解决这个问题?在此先感谢您的帮助!

0 个答案:

没有答案
相关问题