如何避免“错误LNK2005:”(已经定义的stdlib函数)当编译libpng与Microsoft Visual Studio ’08?

前端之家收集整理的这篇文章主要介绍了如何避免“错误LNK2005:”(已经定义的stdlib函数)当编译libpng与Microsoft Visual Studio ’08?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
(为什么我试图这样做:我没有运气在Windows上使用libpng的预构建二进制文件(尽管多次尝试和错误),因此我正在尝试自己编译,我发现 this helpful blog post关于这个,完成与Microsoft Visual Studio 2008项目文件,但不幸的是仍然无法使用它。)

链接到zlib二进制文件here时,它成功编译,但是当尝试将其链接到测试文件时,我收到以下内容

  1. C:\Documents and Settings\Administrator\My Documents>cl "C:\Documents and Settin
  2. gs\Administrator\My Documents\test.c" "C:\Documents and Settings\Administrator\M
  3. y Documents\libpng.lib" -I "C:\Documents and Settings\Administrator\My Documents\include"
  4.  
  5. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
  6. Copyright (C) Microsoft Corporation. All rights reserved.
  7.  
  8. test.c
  9. Microsoft (R) Incremental Linker Version 9.00.30729.01
  10. Copyright (C) Microsoft Corporation. All rights reserved.
  11.  
  12. /out:test.exe
  13. test.obj
  14. "C:\Documents and Settings\Administrator\My Documents\libpng.lib"
  15. MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _abort already defined in LIBCMT.lib(
  16. abort.obj)
  17. MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _fread already defined in LIBCMT.lib(
  18. fread.obj)
  19. MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _malloc already defined in LIBCMT.lib
  20. (malloc.obj)
  21. MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _free already defined in LIBCMT.lib(f
  22. ree.obj)
  23. MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: ___iob_func already defined in LIBCMT
  24. .lib(_file.obj)
  25. LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
  26. se /NODEFAULTLIB:library
  27. test.exe : fatal error LNK1169: one or more multiply defined symbols found

任何人都可以关心如何解决这些错误

问题是两个项目之一是使用多线程DLL,而另一个项目是使用多线程(没有DLL)在项目属性 – >配置属性 – > C/C++ – >代码生成

发生了几次。

确保即使对于发行版本进行“同步”设置,也可以为每种可能的组合(调试,非调试等)进行“同步”

猜你在找的Windows相关文章