gpt4 book ai didi

c++ - 添加类后项目链接错误

转载 作者:太空狗 更新时间:2023-10-29 20:13:53 24 4
gpt4 key购买 nike

我正在为大学编写 3D 图像引擎(它读取带有场景信息的 XML,并使用 openGL 打印),在 visual studio 中(不幸的是......),我正在做解析器 atm,它读取将xml转化为一个简单的树状数据结构。其中一个元素是 Camera,在我添加那部分数据结构之前,程序运行正常,但在我添加它之后,出现以下错误:

1>LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ) already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(_fpinit_.obj) : error LNK2005: __fltused already defined in a previous module
1>LIBCMT.lib(_fpinit_.obj) : error LNK2005: __ldused already defined in a previous module
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isalpha already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isspace already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isalnum already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)
1>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LIBCMT.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR100D.dll)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>bin\CGFexample.exe : fatal error LNK1169: one or more multiply defined symbols found

我不明白为什么添加一个简单的新类会产生如此奇怪的错误,有人可以帮忙吗?

附言如果需要,我会添加相机类,但它实际上只是一堆带有 sets 和 gets 的变量以及两个子类(有两种类型的相机),我认为问题不是因为类本身。

最佳答案

如@John 所述,您应该使用动态或静态 C 运行时链接。在 Visual Studio 中,这由 RunTime Library property(C/C++ 文件夹 > 代码生成 > Runtime Library 属性)控制。 C 运行时有 4 个选项:调试/发布和静态/动态。

旁注:如果您使用的是第 3 方 dll, list 文件应该会为您提供有关正在使用的运行时的一些信息。您可以使用 Dependency Walker 等工具仔细检查它(在动态的情况下,您将看到一个名为 MSVCRXXX.DLL 的 dll)带有 XXX 的 VC 版本和 D 用于调试

关于c++ - 添加类后项目链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19134821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com