bombomby / optick

C++ Profiler For Games
https://optick.dev
MIT License
2.95k stars 296 forks source link

miniz symbols are being exported into global namespace causing linker errors #126

Open aclysma opened 3 years ago

aclysma commented 3 years ago

I'm trying to use the basis universal library and optick profiler client code in the same binary. Unfortunately, they both are exporting the same public symbols.

(optick_miniz.o) : error LNK2005: mz_adler32 already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: mz_crc32 already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: mz_free already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_compress already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_compress_buffer already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_compress_mem_to_heap already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_compress_mem_to_mem already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_compress_mem_to_output already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_get_adler32 already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_get_prev_return_status already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_init already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_write_image_to_png_file_in_memory already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tdefl_write_image_to_png_file_in_memory_ex already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tinfl_decompress already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tinfl_decompress_mem_to_callback already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tinfl_decompress_mem_to_heap already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)
(optick_miniz.o) : error LNK2005: tinfl_decompress_mem_to_mem already defined in libbasis_universal_sys-3b15cfc13ef74b27.rlib(basisu_comp.o)

Would it make sense to wrap miniz in a namespace to avoid this symbol conflict?

https://github.com/BinomialLLC/basis_universal/blob/master/encoder/basisu_miniz.h https://github.com/bombomby/optick/blob/master/src/optick_miniz.cpp

(I will open the same issue for the other project as well)

MatthewLoveday commented 2 years ago

I'm also seeing this issue, since optick is the dependency I have control over I've just excluded optick_miniz.cpp from the build but it would be nice for this to not conflict out of the box.