please help with link error LNK2005 (png.lib?)
-
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. -
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.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
-
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
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)
-
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.