如何避免"错误LNK2005:" (已定义的函数STDLIB)的libpng编译时与Microsoft Visual Studio '08? [英] How to avoid "error LNK2005:" (already defined stdlib functions) when compiling libpng with Microsoft Visual Studio '08?

查看:238
本文介绍了如何避免"错误LNK2005:" (已定义的函数STDLIB)的libpng编译时与Microsoft Visual Studio '08?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(为什么我试图做到这一点:我曾在使用Windows上的libpng的pre-生成的二进制文件没有运气(尽管多小时的试错),所以我现在在尝试编译它自己我发现这是很有帮助的博客帖子有关本,完全与Microsoft Visual Studio 2008的项目文件,可惜仍然没有能够使用它。)

(Why I am trying to do this: I have had no luck in using the pre-built binaries for libpng on Windows (despite many hours of trial and error), and therefore am now trying to compile it myself. I found this helpful blog post concerning this, complete with a Microsoft Visual Studio 2008 project file, but unfortunately have still not been able to use it.)

它链接到发现zlib的二进制<一当编译成功href=\"http://go2.word$p$pss.com/?id=725X1342&site=bobobobo.word$p$pss.com&url=http%3A%2F%2Fwww.zlib.net%2Fzlib123-dll.zip\">here,但试图将其链接到一个测试文件我收到以下时:

It successfully compiles when linking to the zlib binary found here, but when attempting to link it to a test file I receive the following:


    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

谁能在意到一些线索,以如何解决这些错误?

Could anyone care to shed some light as to how to fix these errors?

推荐答案

现在的问题是,这两个项目的人使用的多线程DLL ,而另一种是采用多线程(无DLL),则它在项目属性 - >配置属性 - > C / C ++ - > code代

The problem is that one of the two projects is using Multi-threaded DLL while the other is using Multi-threaded (without DLL in it) in Project Properties -> Configuration Properties -> C/C++ -> Code generation.

在我身上发生了好几次。

Happened to me several times.

确认同步,即使是松开设定的构建,并为每个可能的组合(调试,调试非等)

Make sure to "synchronize" that setting even for release builds, and for each possible combination (debug, non debug, etc)

这篇关于如何避免&QUOT;错误LNK2005:&QUOT; (已定义的函数STDLIB)的libpng编译时与Microsoft Visual Studio '08?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆