strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.77k stars 306 forks source link

Duplicated symbol error #1365

Closed daeho-ro closed 2 weeks ago

daeho-ro commented 2 weeks ago

During the static build with examples,

duplicated symbol error happen.

  duplicate symbol '__Z16fourcc_to_stringj' in:
      /private/tmp/libheif-20241101-9937-gl06de/libheif-1.19.1/static/examples/CMakeFiles/heif-info.dir/heif_info.cc.o
      ../libheif/libheif.a[16](common_utils.cc.o)
  ld: 1 duplicate symbols
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

And indeed, there are two symbol definition for fourcc_to_string and so want to let you know here.

Thanks,

farindk commented 2 weeks ago

Thanks. Does the above change (making the function static) also fix this?

I tried to reproduce this on Linux with BUILD_SHARED_LIBS=OFF and WITH_REDUCED_VISIBILITY=OFF, but don't get that error. Any idea what combination leads to the linker error?

daeho-ro commented 2 weeks ago

Here is the running command,

cmake -S . -B static -DCMAKE_INSTALL_RPATH=@loader_path/../lib -DWITH_DAV1D=OFF -DWITH_GDK_PIXBUF=OFF -DWITH_RAV1E=OFF -DWITH_SvtEnc=OFF -DCMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/libheif/1.19.1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/opt/homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -DBUILD_SHARED_LIBS=OFF
cmake --build static

but anyway, your fix is working good. Thank you!

kmilos commented 2 weeks ago

See also a different duplicated symbol error when linking w/ libheif 1.19.1: https://github.com/darktable-org/darktable/issues/17770#issue-2631444369

Note also that darktable is built w/ C++17.

farindk commented 2 weeks ago

dllexport changed in 26050190264a1c70d27963712a083ac284267c06