I am on win7 64bit home edition. All of my projects are set to build in a 32bit environment using C++. I have successfully built libpng in debug mode using MDd runtime. I have two active projects. My first project is in VS2010 and my second is in VS2012. Within my computer I created an environment variable set to the path for this library to make linking easier in my projects. Both my projects are using MDd as well as multibyte which is the same that libpng uses. All of my paths and dependencies are correct. I also copied over the libpng16.dll into both projects within the same directory as their built executable. I can successfully compile and build both projects. My VS2010 project runs and renders the loaded PNG graphic, however my project in VS2012 doesn't. It crashes when I call png_read_png throwing and unhandled exception that breaks on this line:
check = fread( data, 1, length, png_voidcast( png_FILE_p, png_ptr->io_ptr ) );
within pngrio.c. giving this error:
First-chance exception at 0x77308E19 (ntdll.dll) in Game_debug.exe: 0xC0000005:
Access violation writing location 0x00000014.
The problem is not within my source code since I know that it works in my VS2010 project and I am using the same implementation to load the png in my VS2012 project. I am not sure off hand if it makes a difference that the library I am linking to was built in VS2010 or if there are some command line / compiler settings within the VS2010 built library that my VS2012 project doesn't like. I've read through the png documentation and searched online for hours and couldn't seem to find anything relevant. Any kind of help, tips, pointers or suggestions would do me a great deal.
After considerable hours of trial and errors, and with the little bit of help from others I was finally able to successfully build my 2012 project using the same version of libpng. What I had to do was in my directories where the libpng is located I had to create 3 Folders
And within each of these 3 folders I had to open libpng' solution within the respected versions of Visual Studio. Build out both release and debugs.
Then on my computer for the environment variables, I had to create not one but 3.
Then go back into my VS2010 and VS2012 projects set the paths using the environment variables accordingly replace the old stale libraries with the newly built ones, did a clean of the solution and both projects work properly!
So in conclusion if you are using outside libraries that you can download from the net that comes with a solution that you need to open and build out yourself to link against and you need this same library for projects across different versions of Visual Studio then you will have to open the solution that came with that library within the same version of Visual Studio that you are planning on using with your current project. I hope that my own situation comes to serve as an answer for others!