【问题标题】:C++/CLI LNK2028 when trying to use static lib of another library尝试使用另一个库的静态库时的 C++/CLI LNK2028
【发布时间】:2012-09-14 19:24:37
【问题描述】:

我在尝试构建 C++/CLI dll 时遇到 LNK2028 错误。我在我的程序中使用了一个名为 pano13 的静态库,并且我正在使用它的一种方法。我的程序中的一切都很好,除了我对库进行的一个方法调用,在那里我得到了这两个确切的例外。

Error   21  error LNK2028: unresolved token (0A00013B) "int __cdecl panoCreatePanorama(struct fullPath * const,int,struct fullPath *,struct fullPath *)" (?panoCreatePanorama@@$$FYAHQAUfullPath@@HPAU1@1@Z) referenced in function "public: int __clrcall Surgeon::Stitcher::StitchImage(class System::Collections::Generic::List<class System::String ^> ^,class System::String ^)" (?StitchImage@Stitcher@Surgeon@@$$FQ$AAMHP$AAV?$List@P$AAVString@System@@@Generic@Collections@System@@P$AAVString@6@@Z)   C:\Users\ndean_000\Documents\Visual Studio 2012\Projects\C#\CameraTest\Surgeon\Surgeon.obj  Surgeon

Error   22  error LNK2019: unresolved external symbol "int __cdecl panoCreatePanorama(struct fullPath * const,int,struct fullPath *,struct fullPath *)" (?panoCreatePanorama@@$$FYAHQAUfullPath@@HPAU1@1@Z) referenced in function "public: int __clrcall Surgeon::Stitcher::StitchImage(class System::Collections::Generic::List<class System::String ^> ^,class System::String ^)" (?StitchImage@Stitcher@Surgeon@@$$FQ$AAMHP$AAV?$List@P$AAVString@System@@@Generic@Collections@System@@P$AAVString@6@@Z)    C:\Users\ndean_000\Documents\Visual Studio 2012\Projects\C#\CameraTest\Surgeon\Surgeon.obj  Surgeon

我在项目设置中包含了 lib 文件,我什至添加了 #pragma 注释语句来包含该库,但是我收到了这个错误。我知道它与本机和托管 C++ 的混合有关,但是我没有使用 clr/pure 编译程序,而是使用 /clr 的默认 clr 编译进行编译。有人知道如何解决它吗?

【问题讨论】:

  • 你从托管调用非托管????
  • 是的,据我所知和所见,我应该能够在未使用 /clr:pure 编译的 C++/CLI dll 中执行此操作。
  • 你是从 C# 代码中调用的吗????
  • 我正在使用 C++ 进行此调用。对 panoCreatePanorama 的调用是 C++/CLI dll 文件中的 C++ 调用。
  • 不太熟悉 C++/CLI 但这可能会有所帮助 voyce.com/index.php/2007/05/11/…

标签: c++ native managed .lib


【解决方案1】:

顺便说一句,我在一段时间前解决了这个问题,但我可能应该说出问题所在。 panotools 库是 C 库,而不是 C++ 库。我不知道 C 库需要在 C++ 中使用 extern C 指令。所以我所要做的就是解决我的问题

extern "C"
{
    #include <panorama.h>
}

其中panorama.h 是panotools C 库的包含文件。我一直想知道 extern C 是干什么用的,现在我终于明白它的用途了。

【讨论】:

    猜你喜欢
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2021-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多