0

our network recently made the switch to CentOS 6 from CentOS 5. Upon compiling with gcc we find that at linking time we find this error.

/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status

Now it seemed that in CentOS5 that our compiler would bypass that.

/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -lz

We are using a heavily modified SCons compiling tool (http://www.scons.org/). I can't figure out this bug and I have no idea where to start. The only difference in these errors is one machine is using centOS 5 and the other is using centOS6. Does anyone have any suggestions?

J

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
jwillis0720
  • 4,329
  • 8
  • 41
  • 74
  • Typical problem is that the object files are for the wrong architecture. Try to unpack `/usr/lib/libz.a` and check the architecture with `file` – Ulrich Dangel Jun 04 '12 at 02:34

1 Answers1

2

I can't figure out this bug and I have no idea where to start.

The problem is that you are building 64-bit program and the linker is finding 32-bit libz.a, or vice versa.

On your CentOS5 machine, the linker skips this incompatible libz.a, and finds another libz.a somewhere else.

On your CentOS6 machine, that somewhere else doesn't exist, so you get an error.

You can find out which libz.a the CentOS5 machine is using: add -Wl,-t flag to your link line and look at the output. Then find which package that libz.a belongs to, and install it on your CentOS6 machine.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362