OpenNURBS and ZLIB?

Hi,

I’m trying to incorporate OpenNURBS into my project and am running into some linking errors with ZLIB:

14>zlibd.lib(inflate.obj) : error LNK2005: inflatePrime already defined in opennurbs.lib(inflate.obj)
14>zlibd.lib(inflate.obj) : error LNK2005: inflateGetHeader already defined in opennurbs.lib(inflate.obj)
14>zlibd.lib(adler32.obj) : error LNK2005: adler32_combine already defined in opennurbs.lib(adler32.obj)
14>zlibd.lib(crc32.obj) : error LNK2005: crc32_combine already defined in opennurbs.lib(crc32.obj)
14>zlibd.lib(deflate.obj) : error LNK2005: deflate_copyright already defined in opennurbs.lib(deflate.obj)
14>zlibd.lib(deflate.obj) : error LNK2005: deflateTune already defined in opennurbs.lib(deflate.obj)
14>zlibd.lib(deflate.obj) : error LNK2005: deflateSetHeader already defined in opennurbs.lib(deflate.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _length_code already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _dist_code already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _tr_init already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _tr_tally already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _tr_flush_block already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _tr_align already defined in opennurbs.lib(trees.obj)
14>zlibd.lib(trees.obj) : error LNK2005: _tr_stored_block already defined in opennurbs.lib(trees.obj)

It looks like not all of the ZLIB symbols are using the “Z_PREFIX” decoration and are colliding with another version of ZLIB I am linking with. It looks like the latest version of ZLIB may fix this, there are considerably more Z_PREFIX defines in the latest zconf.h file:

Would upgrading the ZLIB code in OpenNURBS be a possibility?

Thanks, Darby

PS. I’m using the latest OpenNRUBS code from: https://github.com/mcneel/opennurbs.git

Hi @darbyjohnston,

No, there is no reason to update zlib.

Are you using Visual Studio? What version? Are you linking the static or dynamic library? Did you look at the samples included in the repo?

Any additional details you can provide might be helpful.

– Dale

Hi Dale,

Thanks for the reply; I’m trying to link opennurbs to my application as a static library built using a simple CMake file I wrote. The issue is that my application also links to other libraries that use zlib and that’s causing link errors with the version embedded in opennurbs. This shouldn’t happen because opennurbs specifically defines Z_PREFIX to prevent this (https://github.com/mcneel/opennurbs/blob/7.x/zlib/zconf.h#L40), but it looks like not all of the symbols are actually protected.

The latest version of zlib (v1.2.11) has fixes for most of the missing Z_PREFIX decorations which is why I was asking about the possibility of upgrading. As a test I forked opennurbs and replaced the zlib files:

There was still one symbol missing a Z_PREFIX decoration but after fixing that I can now successfully link to opennurbs.

This is with Visual Studio 2019 on Windows 10.

Thanks, Darby