views:

69

answers:

4

I'm working on a project that already contains the gzip library as follows:

zlib\zlib.h  
zlib\zlib.lib
zlib\zconf.h  

I would like to use the gzip functions from this .lib but am getting the following errors:

Compress.cpp
Linking...
Compress.obj : error LNK2001: unresolved external symbol _gzclose
Compress.obj : error LNK2001: unresolved external symbol _gzerror
Compress.obj : error LNK2001: unresolved external symbol _gzwrite
Compress.obj : error LNK2001: unresolved external symbol _gzopen
.\Debug/files.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.  

The link settings include:
Object/library modules: zlib.lib
Project Options:
zlib.lib

In the file using the gzX() functions, it

#include "zlib/zlib.h"

What else needs to be done here to use these functions?

Thank You.

EDIT: Using Visual Studio 6.0 C++

EDIT2: It turned out the static library I was using had the gz() functions taken out of them. The header file still had them which was misleading.

+1  A: 

you also need to add zlib.lib to your project's libraries: Project properties->Linker->Input->Additional Dependencies.

a1ex07
In VS 6.0 it is there under Additional library path: .\zlib
Tommy
+1  A: 

When the build stops, ctrl-click on the URL to see the more verbose form of the log and check the actual command line passed to the linker. That at least will tell you whether the option to link against zlib is being respected. You may get other useful diagnostic output. One possibility could be that the architecture is different (eg you're building x64 but the lib is x86)

the_mandrill
hmmmm... no link in VS 6.0, I will look for the log file, it does seem as the link is not being respected.
Tommy
+1  A: 

I grabbed the one off here to get zlib to build in windows. If you did the same, you may have forgotten to #define ZLIB_WINAPI before including zlib.h

paquetp
Thanks but not sure that is where they got it from. #define ZLIB_WINAPI no difference.
Tommy
hmmm...this same project has example dsp/dsw files in the 'old' directory...you could use that as a reference...
paquetp
A: 

It turned out the static library I was using had the gz() functions taken out of them. The header file still had them which was misleading.

Tommy