【问题标题】:Problem with statically linking hunspell library in visual studio 2010在 Visual Studio 2010 中静态链接 hunspell 库的问题
【发布时间】:2011-03-08 12:24:39
【问题描述】:

我无法在 Visual Studio 2010 中将 hunspell 库静态链接到我的 C++ 项目。

我下载了 hunspell 并转到 hunspell-1.3.1\src\win_api 文件夹。我在 Visual Studio 2010 中打开了 libhunspell.vcproj 文件并转换了项目。我在Realease 配置中构建了解决方案,它在hunspell-1.3.1\src\win_api\Release\libhunspell 文件夹中生成了“libhunspel.lib”文件。

在我使用 hunpell 的简单 C++ 控制台程序中:

  • 我在 Property Pages/Configuration Properties/VC++ Directories/Library Directories

  • 中添加了这个带有 libhunspel.lib 文件的文件夹
  • 我将“hunspell-1.3.1\src\”文件夹添加到Property Pages/Configuration Properties/VC++ Directories/Include Directories

  • 和“libhunspell.lib”到Property Pages/Linker/Input/Additional Dependancies

但它仍然给我未解决的外部符号错误:

Error   2   error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall Hunspell::spell(char const *,int *,char * *)" (__imp_?spell@Hunspell@@QAEHPBDPAHPAPAD@Z) referenced in function _main   C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj  hunspell_learning
Error   3   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::Hunspell(char const *,char const *,char const *)" (__imp_??0Hunspell@@QAE@PBD00@Z) referenced in function _main   C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj  hunspell_learning
Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::~Hunspell(void)" (__imp_??1Hunspell@@QAE@XZ) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj  hunspell_learning
Error   4   error LNK1120: 3 unresolved externals   C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\Debug\hunspell_learning.exe 1   1   hunspell_learning

我不知道有什么问题。我也尝试使用动态库。在 Release_dll 配置中构建 Hunspell 解决方案,并将我的应用程序中的 Include Directories 更改为 hunspell-1.3.1\src\win_api\Release_dll\libhunspell 并编译。我只需要复制我的可执行程序所在的 libhunspell.dll,以便加载 dll。

【问题讨论】:

    标签: visual-studio-2010 visual-c++ linker static-linking hunspell


    【解决方案1】:

    您需要将“#define HUNSPELL_STATIC”放在 stdafx.h 中的某个位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-29
      • 2011-02-26
      • 1970-01-01
      • 2011-06-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      相关资源
      最近更新 更多