Developer forums (C::B DEVELOPMENT STRICTLY!) > Contributions to C::B

problem with ZLIB

(1/3) > >>

maxest:
i need to use in my project zlib (www.zlib.net). i wrote a code, added zlibwapi.lib in Project -> Build Options -> Linker. now i try to compile the code and i get an error:
C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: cannot find -lzlibwapi.lib
does anyone know what's going on?

MortenMacFly:

--- Quote from: maxest on February 24, 2006, 02:36:38 pm ---C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: cannot find -lzlibwapi.lib

--- End quote ---
You want to use *.lib -> use a MS compiler (such as MSVC Toolkit, it's free).
You want to use *.a  -> use e.g. the MinGW compiler.
There is also a way to convert *.lib to *.a if you really need to use MinGW. Here is how it's done for python:

Create libpython22.a
To create Python extensions, you need to link against the Python library. Unfortunately, most Python distributions are provided with Python22.lib, a library in Microsoft Visual C++ format. GCC expects a .a file (libpython22.a to be precise.). Here's how to convert python22.lib to libpython22.a:
   1. Download pexport (from here or http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
   2. Get Python22.dll (it should be somewhere on your harddrive).
   3. Run : pexports python22.dll > python22.def
      This will extract all symbols from python22.dll and write them into python22.def.
   4. Run : dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a
      This will create libpython22.a (dlltool is part of MinGW utilities).
   5. Copy libpython22.a to c:\python22\libs\ (in the same directory as python22.lib).

"This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries."
Morten.

thomas:
I don't know what zlibwapi.lib is, but it does not look like the correct thing.

An easy way to use zlib with MinGW that works (I know for sure because I've done it just 2 days ago) is this:
1. Download and unpack the zlib-1.23 source zipfile
2. Open a cmd prompt and cd to the top level folder
3. type mingw32-make -f win32\Makefile.gcc
4. Wait until it is done (about 6-8 seconds), then copy the libraries (most importantly the .a and .dll) to your lib folder
(so much for setup, now for the fun stuff)
5. Make a project, write your program etc.
6. Be sure that your lib folder is in the linker's search path (normally that is the case)
7. Add z to the "Link libraries" field in project options (or alternatively, specify the absolute path)

maxest:
i just knew that i would have to "compile" something, just as i did it with SDL
everything works. great THX!

maxest:
one more problem..
i wanted to compile the same code while using ms visual c++ and it doesn't work. it gives errors:
src.obj : error LNK2001: unresolved external symbol _compress
Debug/ZLIB.exe : fatal error LNK1120: 1 unresolved externals
i don't understand, i linked zlibwapi.lib. do you know what may be the cause?
(sorry for asking about ms visual c++ on code::blocks forum but this is a very similiar problem :))

Navigation

[0] Message Index

[#] Next page

Go to full version