Jump to content
  • Advertisement
Sign in to follow this  
Daichi

libpng & zlib compile problems

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having problems trying to get libpng up and running so I can read PNG files. I've been able to successfully run the makefile to build zlib 1.2.1 but I'm having little luck with libpng 1.2.7. Having problems with both the makefile and the VC6 project file. It seems like it can't find a static library named "zlib1.lib" I can't figure anything about it myself, a search on the board here produces nothing and google & google groups isn't very helpful either. I also notice in the readme for the VS Project file, it says it Assumes * The zlib project files are in ..\..\..\zlib\projects\visualc6 O_o I also don't see this anywhere, Did i download the Right stuff? Or am I supposed to build this myself? If so how? I've been trying to figure this out all day with no luck >_<; Any help at all would be most appreciated -Daichi

Share this post


Link to post
Share on other sites
Advertisement
Project>Settings Link Tab. 'Object/Library Modules:' Remove zlib1.lib -there is no such library file in zlib or libpng. This should resolve that linking error.

If you would like to set up the linker directories so it can find the actual zlib.lib, then go to Tools>Options and use the Directories tab. In the "Show directories for:" combo box, select "Library files" and add the path where zlib.lib will be.

Once you have resolved this issue, you can tell us if you have any more problems that you are having difficulty with and we can then help you further.

gl hf

Share this post


Link to post
Share on other sites
Thank you, I got the static library and dlls to compile and those are now added to my paths.

It seems like I can get something small to compile with the libpng dll, but i'm not having any luck with it as the static library. I guess for the most part its not that big a deal right now. Anyway, with the static library I'm getting linking errors with MSVCRT.dll

Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in LIBCD.lib(sprintf.obj)
... <condensed version>
_strncpy, _malloc, _free already defined in LIBCD.lib (?.obj)

LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library

-Daichi

Share this post


Link to post
Share on other sites
TravisWells could you elaborate a little more on that?

Another problem I'm running into now is that it errors out on the png_read_image function to work. I'm getting a dialog saying 'Unhandled exception in blah.exe (NTDLL.DLL)...'

Doing some searching, it seems like this error has popped up before but I didn't find much on how to solve the problem.
-Daichi

Share this post


Link to post
Share on other sites
You can get that if you are reading a corrupt file. The Gimp used to generate malformed pngs a few verions back so I would have to keep saving the pngs until they worked properly and then my program would run.

You can add a try-catch block on your png_read_file call and if you catch the exception, you can handle it more elegantly.

Share this post


Link to post
Share on other sites
O_o; Now thats confusing, Something tells me the PNGs that come with the library are not corrupt.
-Daichi

Share this post


Link to post
Share on other sites
Quote:
Original post by TravisWells
You're mixing run-time libraries. You need to compile the program and the static library with the same run-time library.


What this means that if zlib was compiled using the multi-threaded version of the run-time library, and you then try and use the resulting binary in an application which is linking against the single-threaded version, you'll get those sort of errors about "Foo already defined in blah.lib".

All you gotta do is change your code generation options to (I presume) multi-threaded DLL for release builds, and multi-threaded debug DLL for debug builds. That should fix your linker errors.

Share this post


Link to post
Share on other sites
Yup, It was the runtime librarys. Still learning how to use the compiler. ^.^;

I also Found FreeImage, which seems much easier to use so far. Tho it gives me some lengthy compile times with the static librarys. Not a big deal really.

-Daichi

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!