今天在搞畢設時,運行網上的一個SDK,出現如下的錯誤提示
網上查了下,是這個錯誤是由於vs2010全局命名空間中找不到要導出的STL類。修改很簡單:將需要導出的STL類從自定義的類中移動到全局命名空間中。
template class __declspec(dllexport) std::allocator<std::string>;
template class __declspec(dllexport) std::vector<std::string, std::allocator<string>>;
template class __declspec(dllexport) std::allocator<SaveInfo>;
template class __declspec(dllexport) std::vector<SaveInfo>;
template class __declspec(dllexport) std::allocator<int>;
template class __declspec(dllexport) std::vector<int, std::allocator<int>>;
class __declspec(dllexport) SingleObjectDetection
{
public:
//template class __declspec(dllexport) std::allocator<std::string>;
//
//
SingleObjectDetection(void);
~SingleObjectDetection(void);
int start(std::string path);
int getOneFrame(FrameInfo& param);
bool pushOneInfo(const SaveInfo& param);
bool saveInfoToFile(const std::string savePath,int EvaluateType);
void stop();
std::string directoryPath_;
bool isInit_;
private:
bool isInit() const;
private:
std::vector<std::string> imagePathSet_;
int imagePathSetIndex_;
std::vector<SaveInfo> saveInfoSet_;
std::vector<int> randomSet_;
};
將模板實例化部分的放置於全局作用空間,通過編譯。
VS2008中不會認爲第一種代碼是錯誤,從VS2010開始纔將它作爲錯誤。