1

Situation: I have many gzipped input files that I want to process in a c program. I can extract each of them each time i need them but this takes a lot of time, so I would like to use in memory extraction. As a test case i downloaded the zlib sources from http://zlib.net/ and tried to compile the example zpipe.c

Problem: When I compile zpipe.c using:

x86_64-w64-mingw32-gcc -Wall -O3 zpipe.c -o zpipe -L. -lzlib1

I get the error:

x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./zlib1.dll when searching for -lzlib1

x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lzlib1

What I think is the problem (I got this from Skipping incompatible error when linking)

I try to link a 32 bit dll while I compile in 64 bit code. When i look at http://zlib.net/zlib_faq.html#faq26 it is said that zlib is tested on 64 bit machines, but I guess this means you still compile 32 bit code. Note that I compile zpipe.c (provided in the zlib source), so i'm sure the inclusions are all ok. I put the zlib1.dll in the compilation directory.

What did I do/find: Among others I found 2 good examples (however with both of them I have the problem described above)

And I looked at other questions, such as:

I also build a dll myself in vc 2010, however, all project configurations in the zlib 1.26 source are for a 32 bit configuration. So after I build a dll, I have the same error as above.

A long story so a quick summary of my questions:

  1. Is there something I do wrong during compilation?
  2. Is it correct that I will never be able to use the zlib1 dll when I compile in 64 bit?
  3. And most important: Can I somehow compile a 64 bit version of zlib myself (using for example these http://msdn.microsoft.com/en-us/library/9yb4317s.aspx instructions), or are these already available somewhere (I was not able to find these until now)?

Thank you all for your time!

Community
  • 1
  • 1
Martin
  • 1,084
  • 9
  • 15

1 Answers1

0

You can most definitely compile a 64-bit version yourself. Open your DLL-project in Visual Studio, go into the configuration manager and create a new configuration for 64-bit. The instructions you linked should be fine.

If you are having problem with this you can also include the source of zlib in your application instead of linking against the DLL.

rasmus
  • 3,136
  • 17
  • 22
  • Yes, I'm trying this now, unfortunately this just leads to another problem as here: http://stackoverflow.com/questions/8044385/64-bit-build-on-microsoft-visual-c-express-2010 To come back to my question, it is correct that I will never be able to use the 32bit zlib dll unless I compile my code in 32 bit as well? – Martin Feb 11 '12 at 12:10
  • Ok, in the end this all works, so lets say my problem is solved :) – Martin Feb 13 '12 at 09:20