Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. please help with link error LNK2005 (png.lib?)

please help with link error LNK2005 (png.lib?)

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++questionperformanceannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ryuki
    wrote on last edited by
    #1

    Ok, VC++ tells me the same errors all the time: MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf allready defined in LIBCD.lib(sprintf.obj) As far as I understand it, it is a problem with incompatibel iostream librarys. VC++ chooses the right version itself but now there is a conflict since I build something in that requires different iostream versions. I put some png reading code in my previous well working project. I used the same code in another project without any trouble. But last time it was an MFC application and now it is a simple VC++ win32 application project. Maybe the way I linked the library caused some trouble too. I had to use that methode: extern "C" { #include "png.h" #include "pngconf.h" } other includes are #include "ddraw.h" #include "windows.h" #include "windowsx.h" #include "mmsystem.h" #include "iostream.h" #include "conio.h" #include "stdlib.h" #include "malloc.h" #include "memory.h" #include "string.h" #include "stdarg.h" #include "stdio.h" #include "math.h" #include "io.h" #include "fcntl.h" How can I get rid of this annoying link errors? Every help is welcome.

    C S 2 Replies Last reply
    0
    • R ryuki

      Ok, VC++ tells me the same errors all the time: MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf allready defined in LIBCD.lib(sprintf.obj) As far as I understand it, it is a problem with incompatibel iostream librarys. VC++ chooses the right version itself but now there is a conflict since I build something in that requires different iostream versions. I put some png reading code in my previous well working project. I used the same code in another project without any trouble. But last time it was an MFC application and now it is a simple VC++ win32 application project. Maybe the way I linked the library caused some trouble too. I had to use that methode: extern "C" { #include "png.h" #include "pngconf.h" } other includes are #include "ddraw.h" #include "windows.h" #include "windowsx.h" #include "mmsystem.h" #include "iostream.h" #include "conio.h" #include "stdlib.h" #include "malloc.h" #include "memory.h" #include "string.h" #include "stdarg.h" #include "stdio.h" #include "math.h" #include "io.h" #include "fcntl.h" How can I get rid of this annoying link errors? Every help is welcome.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      ryuki wrote: MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf allready defined in LIBCD.lib(sprintf.obj) MSVCRT is a release version (MSVCRTD is the debug version) LIBCD is a debug version (LIBC is the release version) so, it looks like you're mixing release and debug versions of your app and LibPng. make sure you link debug to debug libraries and release to release. Cleek | Image Toolkits | Thumbnail maker

      R 1 Reply Last reply
      0
      • C Chris Losinger

        ryuki wrote: MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf allready defined in LIBCD.lib(sprintf.obj) MSVCRT is a release version (MSVCRTD is the debug version) LIBCD is a debug version (LIBC is the release version) so, it looks like you're mixing release and debug versions of your app and LibPng. make sure you link debug to debug libraries and release to release. Cleek | Image Toolkits | Thumbnail maker

        R Offline
        R Offline
        ryuki
        wrote on last edited by
        #3

        I just tried something and could fix the problem for the moment. I changed the compiler argument from /MLd to /MDd for debugging and /ML to /MD for release. Now I only got a last warning for MSVCRT.lib (only debug mode): LINK : warning LNK4098: Standard library "MSVCRT" is in conflict with another library; /NODEFAULT:Library used (sorry, I have to translate all messages since I did not use the englisch localisation, so the warning can look different from the one you get)

        1 Reply Last reply
        0
        • R ryuki

          Ok, VC++ tells me the same errors all the time: MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf allready defined in LIBCD.lib(sprintf.obj) As far as I understand it, it is a problem with incompatibel iostream librarys. VC++ chooses the right version itself but now there is a conflict since I build something in that requires different iostream versions. I put some png reading code in my previous well working project. I used the same code in another project without any trouble. But last time it was an MFC application and now it is a simple VC++ win32 application project. Maybe the way I linked the library caused some trouble too. I had to use that methode: extern "C" { #include "png.h" #include "pngconf.h" } other includes are #include "ddraw.h" #include "windows.h" #include "windowsx.h" #include "mmsystem.h" #include "iostream.h" #include "conio.h" #include "stdlib.h" #include "malloc.h" #include "memory.h" #include "string.h" #include "stdarg.h" #include "stdio.h" #include "math.h" #include "io.h" #include "fcntl.h" How can I get rid of this annoying link errors? Every help is welcome.

          S Offline
          S Offline
          Stlan
          wrote on last edited by
          #4

          In the properties of your project, try to specify libcd.lib (and perhaps libc.lib as well) in the field entitled Ignore Specific Library, in the tab Linker > Input.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups