VS2005 Command line compilation errors

W

wxforecaster

As alluded to in my post yesterday, I'm trying to compile a common C utility
in Windows.
It's only reference is to zlib.h, which needs zconf.h and in turn libz.a

On Unix I've compiled this with success by running: gcc -lz -o foo.exe foo.c
(where -lz is a link to 'z' or libz.a)

I've placed zlib.h and zconf.h in the VC include folder, and libz.a and
libz.so in the lib folder.

When I run: cl foo.c
from the VS2005 command line tool, I get the following errors (which are the
same errors I would receive on Unix without linking to the libz.a library by
the -lz commnd line argument). I was under the impression that cl called the
linker automatically, so what am I doing wrong here?

/out:foo.exe
foo.obj
foo.obj : error LNK2019: unresolved external symbol _inflate referenced in
function _main
foo.obj : error LNK2019: unresolved external symbol _inflateInit_ referenced
in function _main
foo.exe : fatal error LNK1120: 2 unresolved externals

Thanks in advance!
Evan
 
B

Brian Muth

wxforecaster said:
As alluded to in my post yesterday, I'm trying to compile a common C
utility in Windows.
It's only reference is to zlib.h, which needs zconf.h and in turn libz.a

On Unix I've compiled this with success by running: gcc -lz -o foo.exe
foo.c
(where -lz is a link to 'z' or libz.a)

I've placed zlib.h and zconf.h in the VC include folder, and libz.a and
libz.so in the lib folder.

When I run: cl foo.c
from the VS2005 command line tool, I get the following errors (which are
the same errors I would receive on Unix without linking to the libz.a
library by the -lz commnd line argument). I was under the impression that
cl called the linker automatically, so what am I doing wrong here?

It is calling the linker automatically. These errors are in fact being
generated by the linker, complaining it doesn't know how to resolve them.
You need a libz.lib and libz.dll somewhere. If the libz.lib is not in the
standard LIB path, you need to explicitly reference it from the command
line.

Brian
 
W

wxforecaster

Brian,

I have tried everything in these regards with placing files in the
lib/include directories. This entire C compilation should have taken about a
minute, but I've wasted hours on it to no avail. I've been to zlib.net and
tried to make heads or tails of this stuff, but I'm honestly at a loss for
straight forward instructions.

Evan
 
B

Ben Voigt

wxforecaster said:
Brian,

I have tried everything in these regards with placing files in the
lib/include directories. This entire C compilation should have taken about
a minute, but I've wasted hours on it to no avail. I've been to zlib.net
and tried to make heads or tails of this stuff, but I'm honestly at a loss
for straight forward instructions.

Just like gcc needs -lz to tell it to look for libz.a, cl needs to have
"zlib.lib" or some such on the command line to instruct it to link with that
library.
 
W

wxforecaster

Yeh, I went the easier route, which was to install the Mingw compiler (win32
equivalent of gcc) and everything is well.

Evan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top