在Microsoft Visual c++ 2015中编译DLL -警告C4251需要有DLL接口供类的客户端使用-当使
Compiling DLL in Microsoft Visual C++ 2015 -- warning C4251 needs to have dll-interface to be used by clients of class -- when using Boost?
所以,我正试图为我的一个大型项目编译一个DLL。我们的想法是把它分成几个部分。编译成DLL的库,以及链接到DLL的应用程序。我一直收到以下警告:
warning C4251: 'plf::lfInvalidIndexExcpt::message': class 'boost::container::basic_string<char,std::char_traits<char>,boost::container::new_allocator<char>>' needs to have dll-interface to be used by clients of class 'plf::lfInvalidIndexExcpt'
这是一直困扰我的代码。
我有我的DLL导出/导入宏定义如下:
#ifdef LF_ENGINE_EXPORTS
#define LFE_API __declspec(dllexport)
#else
#define LFE_API __declspec(dllimport)
#endif
现在,我在库中使用boost,在某一点上我有以下内容:
typedef boost::container::string lfString;
类lfinvalidindexexpt是这样定义的:
namespace plf
{
class LFE_API lfInvalidIndexExcpt
{
public:
explicit lfInvalidIndexExcpt(lfSize idx);
lfInvalidIndexExcpt(lfSize idx, const lfString& descr);
const char* what() const throw();
private:
lfString message;
void makeMessage(lfSize idx, const lfString& descr);
};
};
我应该提到lfSize只是std::size_t的一个类型定义。
我想知道的是这个警告实际上意味着什么,如果我可以在我的DLL中使用这样的Boost,如果有的话。此外,如果这不是正确的方式来使用Boost是什么?
谢谢,
扎克霜
所以,我似乎已经找到了解决我自己的问题,通过玩弄我的代码和窥探周围的StackOverflow!我似乎只需要做的是从类声明中删除DLL导出宏并将其添加到成员函数中。现在它似乎可以编译和工作了!
解决方案来自此StackOverflow帖子(由 first 回答):std::vector需要有dll接口由类'X警告
相关文章:
- 挂起和取消挂起一个文件DLL
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 导入库可以跨dll版本工作吗
- 从C++dll访问C#中的一行主要参数
- 链接到自行创建的dll失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- C++:将外部库链接到dll库
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 不同的Visual Studio版本中缺少.dll
- 从DLL中删除类的实例
- 如何包装第三方DLL在R中使用
- 使用c#访问c++dll中带有char*参数的函数时发生AccessViolationException
- 系统.将数组移交给c#中动态加载的c++DLL时发生AccessViolationException
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 当我使用 C++ 中的 C# dll 来使用 Selenium 时,存在异常处理问题
- Python ctypes:不会按预期加载 dll
- 在Microsoft Visual c++ 2015中编译DLL -警告C4251需要有DLL接口供类的客户端使用-当使