error LNK2005 int __cdecl 解决方案【转】

时间:2023-03-09 17:11:05
error LNK2005 int __cdecl 解决方案【转】

error LNK2005: "int __cdecl isPtInPolygon(class std::vector<struct double2,class std::allocator<struct double2> > &,struct double2)" (?isPtInPolygon@@YAHAAV?$vector@Udouble2@@V?$allocator@Udouble2@@@std@@@std@@Udouble2@@@Z) already defined in _GlWidget.obj
1>Debug/StrokeBar.exe : fatal error LNK1169: one or more multiply defined symbols found

解决:
在 属性->配置属性->链接器->命令行中添加   /FORCE:MULTIPLE

这个选项告诉链接器去创建一个有效的exe文件或dll文件,即使一个函数或变量被引用,但多处定义。
这样生成的文件可能不会按照我们想象的那样执行。