gpt4 book ai didi

c - 使用 Microsoft Visual Studio '08 编译 libpng 时如何避免 "error LNK2005:"(已定义的 stdlib 函数)?

转载 作者:太空狗 更新时间:2023-10-29 16:31:39 27 4
gpt4 key购买 nike

(为什么我要尝试这样做:我没有运气在 Windows 上使用 libpng 的预构建二进制文件(尽管经过许多小时的反复试验),因此我现在尝试自己编译它。我发现this helpful blog post关于这个,配了一个Microsoft Visual Studio 2008工程文件,可惜还是没能用。)

它在链接到找到的 zlib 二进制文件时成功编译 here ,但是在尝试将其链接到测试文件时,我收到以下信息:

    C:\Documents and Settings\Administrator\My Documents>cl "C:\Documents and Settin    gs\Administrator\My Documents\test.c" "C:\Documents and Settings\Administrator\M    y Documents\libpng.lib" -I "C:\Documents and Settings\Administrator\My Documents\include"    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86    Copyright (C) Microsoft Corporation.  All rights reserved.    test.c    Microsoft (R) Incremental Linker Version 9.00.30729.01    Copyright (C) Microsoft Corporation.  All rights reserved.    /out:test.exe    test.obj    "C:\Documents and Settings\Administrator\My Documents\libpng.lib"    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _abort already defined in LIBCMT.lib(    abort.obj)    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _fread already defined in LIBCMT.lib(    fread.obj)    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _malloc already defined in LIBCMT.lib    (malloc.obj)    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _free already defined in LIBCMT.lib(f    ree.obj)    MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: ___iob_func already defined in LIBCMT    .lib(_file.obj)    LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u    se /NODEFAULTLIB:library    test.exe : fatal error LNK1169: one or more multiply defined symbols found

任何人都可以阐明如何修复这些错误吗?

最佳答案

问题是这两个项目中的一个正在使用多线程 DLL,而另一个在项目属性中使用多线程(其中没有 DLL)-> 配置属性 -> C/C++ -> 代码生成。

发生在我身上好几次。

即使对于发布版本和每个可能的组合(调试、非调试等),也要确保“同步”该设置

关于c - 使用 Microsoft Visual Studio '08 编译 libpng 时如何避免 "error LNK2005:"(已定义的 stdlib 函数)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1937937/

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