在Visual Studio 2013中尝试使用sqlite3_open进行编译时出错 [英] Error when trying to compile using sqlite3_open in Visual Studio 2013

查看:709
本文介绍了在Visual Studio 2013中尝试使用sqlite3_open进行编译时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个Cocos2dx(c ++)win 32项目,并试图使用sqlite来保存游戏数据。我现在对c ++ / Visual Studio的了解非常有限。

I'm working in a Cocos2dx (c++) win 32 project and trying to use sqlite to save the game data. My knowledge of c++ / Visual Studio is very limited right now.

这是我想要编译的代码的一部分。

This is part of the code that I'm trying to compile.

#include <sqlite3\include\sqlite3.h>
...
void HelloWorld::SaveAndLoadTest()
{
 sqlite3 *pdb = NULL;    
 sqlite3_open("writablePath", &pdb);
 ...
}

但是当我尝试编译行sqlite3_open命令我得到以下错误:

But when I try to compile the line with the sqlite3_open command I get the following error:

错误7错误LNK2019:未解决的外部符号_sqlite3_open在函数... / strong>

Error 7 error LNK2019: unresolved external symbol _sqlite3_open referenced in function...

我一直在试图找到这个小时的答案。我发现最类似的问题是这一个,但我不明白答案。
错误:未定义引用`sqlite3_open'

I've been trying to find an answer for this many hours. The most similar question I found was this one but I don't understand the answer. Error: undefined reference to `sqlite3_open'


您需要将sqlite3库与您的程序链接:

g++ main.cpp -lsqlite3



$ b b

我是Visual Studio新手,我不明白如何解决这个问题,任何人?

I'm new to Visual Studio and I don't understand how to solve this, anyone?

推荐答案

错误LNK2019意味着引用可能丢失,因为库是mising。

The error LNK2019 means that references are missing probably because a library is mising.

要将sqlite添加到MSVC项目,您必须确保:

To add sqlite to a MSVC project, you have to make sure that:


    < />
  • sqlite3.dll 位于可执行文件的路径或目录中
  • li>
  • 并且将 sqlite3.lib 添加到VS项目中的附加依赖项中(项目>链接器>输入>附加依赖项的选项)

  • the header is included in your source files
  • sqlite3.dll is in the path or in the directory of the executable
  • AND that sqlite3.lib is added to the additional dependencies in the VS project (options of the project > Linker > Input > Additional dependencies)

最后一点是必须的,因为lib告诉链接器哪些函数存储在dll中。

This last point is mandatory, because the lib tells the linker which functions are stored in the dll.

这篇关于在Visual Studio 2013中尝试使用sqlite3_open进行编译时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆