乘以定义的标准分配器

Multiply defined standard allocator

本文关键字:标准分 分配器 标准 定义      更新时间:2023-10-16

我正在尝试用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是使用nvcc编译的,但据我所知,我给了nvcc与其他文件完全相同的编译器选项。

我能做什么,这个错误可能来自哪里?

确保您使用相同的运行时库,查看如何设置项目的答案。具体来说,确保您使用/MTd用于CUDA构建规则和标准C/c++构建(或/MT)。