Pergunta

I am having a LNK2028 error when I try to build my C++/CLI dll. I am using a static lib called pano13 in my program, and I am using one method of it. Everything in my program is fine except the one method call I make to the library, where I get these exact two exceptions.

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

I am including the lib file in the project settings, and I even added the #pragma comment statement for including the library, however I am getting this error. I understand that it has to do with the mixing of native and managed C++, however I am not compiling the program with clr/pure, it is being compiled with the default clr compilation of /clr. Anyone have any ideas how to fix it?

Foi útil?

Solução

By the way, I solved this a WHILE ago, but I should probably say what the issue was. The panotools library is a C library, not a C++ library. I didn't know that C libraries needed the extern C directive to be used in C++. So all I had to do to fix my problem was

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

Where panorama.h is the include file for the panotools C library. I've always wondered what extern C was for and now I finally understand its purpose.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top