codeblocks, libpng and zlib

Started by
5 comments, last by broady 15 years, 9 months ago
Hello guys, i am having troubles with the libpng library. Well i downloaded the libpng-1.2.24-lib wich contains the development files. There are 2 sub-dir in it, the include and the lib one. As i did with glut(working greatly atm), i copyied the content of the 2 directorys respectively in mingw/include and mingw/lib and copyied every dll file in windows/system so vista can find em. I created a new empty project in CB. From the build options i linked the libpng.lib and i am trying to compile the pngtest.c example. When i compile i have a lot of compiling errors and many of 'em refer to the zlib library. I googled a lot without luck. I don't khnow where i can take this zlib. Expecially i can't find informations about zlib with vista. It's all the morning i am trying to do this stuff. PS: is it right what i did to install libpng? EDIT: cam someone explain me why there are .dll and .dll.a files? Guys scuse me but i am new to these kind of things. Thanks guys Bro
Advertisement
I am going in crazy. Once found the zlib i did the some exaxt operations (include, lib and dll stuff).

Now when i go to compile i hace 2 errors:

C:\Users\bro\codice\hello\main.c|1338|undefined reference to `_png_libpng_ver'|
the other 1 is the same but on a different line.

From the linker tab (in build options for the current project) i added libpng.lib and zlib.lib.
Quote:As i did with glut(working greatly atm), i copyied the content of the 2 directorys respectively in mingw/include and mingw/lib and copyied every dll file in windows/system so vista can find em.
I consider this a very bad thing to do. If you have to copy to the compiler include and lib directories, because you haven't learned about passing in arguments for additional include and lib directories... I also don't start polluting my windows directory with dlls. Dlls are not absolute things that are fixed. There can be different versions, or modified versions, because, err, the underlying code isn't fixed.

Quote:When i compile i have a lot of compiling errors and many of 'em refer to the zlib library.
Yes, because libpng uses compression from zlib.

Quote:cam someone explain me why there are .dll and .dll.a files
A dll is it's own binary. When you want to make use of whatever is in a dll, it takes some additional code on your part to use it. Which is an option, unless you use what the compiler provides you. It's possible to link to an import library that automatically sets your program to use a dll. If you don't link to it, you have to manually load the dll, which may be what you want, but if you're asking, most likely not.

The format mingw uses for static libraries is the .a file you see. So the import library is named by dllname.a to indicate what dll has what import library.
Quote:Original post by oler1s
Quote:As i did with glut(working greatly atm), i copyied the content of the 2 directorys respectively in mingw/include and mingw/lib and copyied every dll file in windows/system so vista can find em.
I consider this a very bad thing to do. If you have to copy to the compiler include and lib directories, because you haven't learned about passing in arguments for additional include and lib directories... I also don't start polluting my windows directory with dlls. Dlls are not absolute things that are fixed. There can be different versions, or modified versions, because, err, the underlying code isn't fixed.

Quote:When i compile i have a lot of compiling errors and many of 'em refer to the zlib library.
Yes, because libpng uses compression from zlib.

Quote:cam someone explain me why there are .dll and .dll.a files
A dll is it's own binary. When you want to make use of whatever is in a dll, it takes some additional code on your part to use it. Which is an option, unless you use what the compiler provides you. It's possible to link to an import library that automatically sets your program to use a dll. If you don't link to it, you have to manually load the dll, which may be what you want, but if you're asking, most likely not.

The format mingw uses for static libraries is the .a file you see. So the import library is named by dllname.a to indicate what dll has what import library.


Dear oler1s, i thank you for your reply. U didn't help me a lot but, without offence. As u can see i am quite new to this world. At school i wrote a lot of code (OOP mainly) but i always used just the standard c++ library. Im am trying to understand the DLL world and believe me it's not so easy to find good resources. If u write me "what u do is a bad thing, u do this coz u don't khnow how to...." u don't help me a lot. Isn't easier and fater throw a link with some clear resource?

Have a nice day
Bro


I am still looking for stuff without luck. If u have some tip reply please.

EDIT: if i link even libpng.dll.a (i am trying all) i have no compiling errors but i got an error since CB is not able to find libpng3.dll (note the 3). I haven't this file, googled a lot and nothing.

Bro

[Edited by - broady on July 14, 2008 10:51:50 AM]
It sounds to me like you need to read up on how the compiler tool-chain works. Advising Google or Wikipedia is a good start. Some useful search-strings include "Static linking", "Dynamic linking", "Object files" & "Code libraries".

I would also recommend building both libpng and zlib from source, you can consult the README's of the libraries, your compiler's (I assume you're using MinGW) and Code::Blocks' documentation on how to do this.

Good luck!
yeah Redien u are right. Tomorrow i will do it.

Good night
Bro

This topic is closed to new replies.

Advertisement