我想在Visual Studio 2008中構建一個開源C++項目。我加載解決方案文件並編譯所有內容,但由於未找到某些方法,我收到了一堆鏈接錯誤。使用DUMPBIN.EXE檢查有問題的.lib文件後,我可以看到問題所在:.lib中的方法在它們的簽名中都有__cdecl
,而鏈接器正在尋找與__thiscall
相同的方法。如何讓VS2008在C++項目中使用__cdecl而不是__thiscall?
如何讓VS 2008使用__cdecl
代替?
注意:該項目是a fork of CCV,基於OpenCV的多點觸控跟蹤程序。此叉的目的是通過相機制造商提供的FlyCapture2庫爲稱爲Flea3的相機提供支持。這裏是鏈接錯誤:
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FlyCapture2::Image::Image(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall ofxFlea3::ofxFlea3(void)" ([email protected]@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall FlyCapture2::Image::~Image(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall ofxFlea3::ofxFlea3(void)" ([email protected]@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FlyCapture2::Camera::Camera(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall ofxFlea3::ofxFlea3(void)" ([email protected]@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall FlyCapture2::Camera::~Camera(void)" ([email protected]@@[email protected]) referenced in function "public: __thiscall ofxFlea3::ofxFlea3(void)" ([email protected]@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall FlyCapture2::Error::~Error(void)" ([email protected]@@[email protected]) referenced in function "void __cdecl PrintError(class FlyCapture2::Error)" ([email protected]@[email protected]@@@Z)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall FlyCapture2::Error::PrintErrorTrace(void)const " ([email protected]@[email protected]@UBEXXZ) referenced in function "void __cdecl PrintError(class FlyCapture2::Error)" ([email protected]@[email protected]@@@Z)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class FlyCapture2::Error __thiscall FlyCapture2::BusManager::GetCameraFromIndex(unsigned int,class FlyCapture2::PGRGuid *)" ([email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall FlyCapture2::BusManager::~BusManager(void)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FlyCapture2::Error::Error(class FlyCapture2::Error const &)" ([email protected]@@[email protected]@@Z) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class FlyCapture2::Error __thiscall FlyCapture2::BusManager::GetNumOfCameras(unsigned int *)" ([email protected]@[email protected]@[email protected]@[email protected]) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FlyCapture2::Error::Error(void)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FlyCapture2::BusManager::BusManager(void)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall ofxFlea3::listDevices(void)" ([email protected]@@QAEXXZ)
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class FlyCapture2::Error __thiscall FlyCapture2::Image::Save(char const *,enum FlyCapture2::ImageFileFormat)" ([email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "public: void __thiscall ofxFlea3::initFlea3(int,int,int,int)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class FlyCapture2::Error __thiscall FlyCapture2::Image::Convert(enum FlyCapture2::PixelFormat,class FlyCapture2::Image *)const " ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "public: void __thiscall ofxFlea3::initFlea3(int,int,int,int)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class FlyCapture2::Error __thiscall FlyCapture2::Image::ReleaseBuffer(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "protected: virtual void __thiscall ofxFlea3::getNewFrame(unsigned char *)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual struct FlyCapture2::TimeStamp __thiscall FlyCapture2::Image::GetTimeStamp(void)const " ([email protected]@[email protected]@[email protected]@XZ) referenced in function "protected: virtual void __thiscall ofxFlea3::getNewFrame(unsigned char *)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual unsigned char * __thiscall FlyCapture2::Image::GetData(void)" ([email protected]@[email protected]@UAEPAEXZ) referenced in function "protected: virtual void __thiscall ofxFlea3::getNewFrame(unsigned char *)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual unsigned int __thiscall FlyCapture2::Image::GetDataSize(void)const " ([email protected]@[email protected]@UBEIXZ) referenced in function "protected: virtual void __thiscall ofxFlea3::getNewFrame(unsigned char *)" ([email protected]@@[email protected])
1>ofxFlea3.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall FlyCapture2::Image::GetDimensions(unsigned int *,unsigned int *,unsigned int *,enum FlyCapture2::PixelFormat *,enum FlyCapture2::BayerTileFormat *)const " ([email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "protected: virtual void __thiscall ofxFlea3::getNewFrame(unsigned char *)" ([email protected]@@[email protected])
你正在做一些嚴重錯誤的事情,比如#include庫中的.h文件在C++類中。不提供項目名稱或顯示鏈接器錯誤不能幫助我們幫助您。 – 2013-02-18 23:55:13
@HansPassant,10-4,我添加了項目鏈接和鏈接器錯誤。 – Ghopper21 2013-02-19 03:37:56