多重定义的标准分配器
我正在尝试使用 VC++2008 编译 C++ DLL。我已经使用 VC++2010 正确编译了它,但使用 VC++2008 时,出现以下错误:
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned short * __cdecl std::allocator<unsigned short>::allocate(unsigned __int64)" (?allocate@?$allocator@G@std@@QEAAPEAG_K@Z) already defined in cuda.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned short * __cdecl std::allocator<unsigned short>::allocate(unsigned __int64)" (?allocate@?$allocator@G@std@@QEAAPEAG_K@Z) already defined in cuda.obj
cuda.obj
is generated using nvcc
, but as far as我可以看出,我为 nvcc 提供了与其他文件完全相同的编译器选项。
我能做什么,这个错误可能来自哪里?
I am trying to compile a C++ DLL with VC++2008. I already compiled it correctly with VC++2010, but with VC++2008, I get the following error:
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned short * __cdecl std::allocator<unsigned short>::allocate(unsigned __int64)" (?allocate@?$allocator@G@std@@QEAAPEAG_K@Z) already defined in cuda.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned short * __cdecl std::allocator<unsigned short>::allocate(unsigned __int64)" (?allocate@?$allocator@G@std@@QEAAPEAG_K@Z) already defined in cuda.obj
cuda.obj
is compiled using nvcc
, but as far as I can tell, I gave nvcc the exact same compiler options than for the other files.
What can I do, and where could this error come from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保使用相同的运行时库,请查看 此答案了解如何设置项目。具体来说,请确保对 CUDA 构建规则和标准 C/C++ 构建(或 /MT)使用 /MTd。
Make sure that you use the same runtime library, check out this answer for how to set up the projects. Specifically, make sure you use /MTd for both the CUDA build rule and the standard C/C++ build (or /MT).