Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on Manjaro/Arch (and other systems using OpenCV with OpenEXR 3.2+) if libdeflate isn't explicitly linked #1248

Open
Razzaline opened this issue Oct 19, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@Razzaline
Copy link
Contributor

Razzaline commented Oct 19, 2023

Bug Description

When I compile Tahoma2D, following the Linux build instructions either as is or with a modified PKGBUILD, it always stops around 62% after it says it finished building something, e.g. toonzqt or tnzstdfx, with the error make: *** [Makefile:136: all] Error 2. If I try compiling again a few times, somehow it seems to get past that part and I can even get to 100% (after it says it finished building the Tahoma2D executable) but still have this error. Adding LANG=C and VERBOSE=1 doesn't give any more helpful/meaningful output.

This has been a problem since around August or September, and I don't know what changed.

Edit: Possibly something to do with openexr updating from 3.1.11 to 3.2.0 and installing libdeflate as a dependency (has a linker error, usually further up around 42% or 43%, about undefined references in libimage to libdeflate).

Steps to reproduce

  1. Start building from command line, following instructions
  2. Error occurs

Relevant logs/screenshots

/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_decompressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_compressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_decompress'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress_bound'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_compressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_decompressor'
collect2: error: ld returned 1 exit status

Software Version

Other (Specify below)

Software Version Information

Commit 919d538 (or whichever is latest at the time, since I try again with each commit)

Operating System

Manjaro with Linux kernel 6.5.7

Graphics Card

No response

Drawing Tablet

No response

@Razzaline Razzaline added the bug Something isn't working label Oct 19, 2023
@manongjohn
Copy link
Collaborator

Can you copy/paste the output of the build into a file and add it to this issue so i can see the real compile error which should have been thrown somewhere before it stopped?

@Razzaline
Copy link
Contributor Author

All I saw leading up to the Makefile error was warnings, not build errors, but here's the entire log.
log_1.txt

@Razzaline
Copy link
Contributor Author

Oh, also, OpenToonz has been building fine without any of these errors. It's just Tahoma2D that's having this trouble.

@manongjohn
Copy link
Collaborator

From the log:

/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_decompressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_compressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_decompress'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress_bound'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_compressor'
/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_decompressor'
collect2: error: ld returned 1 exit status

@Razzaline
Copy link
Contributor Author

Razzaline commented Oct 19, 2023

Sometimes I could find that error (usually at the end), but other times it got lost in all the other output so I wasn't sure if it was consistent. But when I tried downgrading libdeflate from 1.19 to 1.18 (that was the only change I could think of on my system in the time that it stopped compiling) that seemingly went away but the makefile error was still there.

@Razzaline
Copy link
Contributor Author

Nevermind, the error is still there even if I downgrade the version (after deleting the build directory and trying again) >.<

@Razzaline Razzaline changed the title Build fails with a makefile error and no other info Build fails: "/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_[...]'" Oct 19, 2023
@Razzaline
Copy link
Contributor Author

It seems like libdeflate was installed as a dependency for openexr at the beginning of September when openexr updated from 3.1.11 to 3.2.0. Maybe the linking process is conflicting with libdeflate being installed in the system?

@manongjohn
Copy link
Collaborator

What is openexr a dependency of? You must be using a newer library of something that is requiring openexr and therefore libdeflate than what I normally build on Ubunutu 20.04 with since those libraries are not in the current builds as far as I can tell.

As for why it can't find libdeflate? Maybe add the location of the libarary to the library path? May need to add -ldeflate to the CMAKE_CXX_FLAGS based on some discussions I found regarding libdeflate linking issues.

@Razzaline
Copy link
Contributor Author

Openexr is mostly a dependency for graphics programs on my system.
Here's the full list:

blender
freeimage
gegl
gimp
gst-plugins-bad
krita
libjxl
opencolorio
opencv
openimageio
synfig

It seems to be finding libdeflate just fine, since it's detected in the configure step. If I downgrade openexr and remove libdeflate then it stops in the configure process because it can't find it, so that doesn't seem to be the problem.

How would I add -ldeflate to the flags?

@manongjohn
Copy link
Collaborator

What version of opencv are you using? Does that require openexr? Did you install that for T2D or was that already there?

You can edit the toonz\sources\CMakeLists.txt. There is a section for CMAKE_C_FLAGS and CMAKE_CXX_FLAGS for Linux builds. Might also be able to add it as an environment variable which would add it.

@Razzaline
Copy link
Contributor Author

I'm using opencv 4.8.1, and it does require openexr. Both of them were already installed for other things long before Tahoma2D, but I wouldn't be sure what in particular (probably one of the graphics programs I mentioned). I found Tahoma2D more recently (maybe a year ago), so I wouldn't have installed openexr specifically for Tahoma2D.

Okay, explicitly linking libdeflate seems to have fixed it!

@Razzaline Razzaline changed the title Build fails: "/usr/bin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_[...]'" Build fails on Manjaro/Arch (and other systems using OpenCV with OpenEXR 3.2+) if libdeflate isn't explicitly linked Nov 11, 2023
@FabioLolix
Copy link

FabioLolix commented Jan 7, 2024

Hello, I'm the maintainer of the AUR pkgbuilds of tahoma2d and tahoma2d-git, in addition to the libdeflate problem I have an issue with libwebp

With libwebp I have that problem since earlier this year, v is 1.3.2, its build option can be seen here https://gitlab.archlinux.org/archlinux/packaging/packages/libwebp/-/blob/main/PKGBUILD?ref_type=heads

[ 47%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/spectrumfield.cpp.o
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIAppend'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPEncode'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_decompressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIDecGetRGB'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_compressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_decompress'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIDelete'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPInitDecBufferInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureImportRGBA'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureFree'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPConfigInitInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress_bound'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPINewDecoder'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPFreeDecBuffer'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureInitInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureImportRGB'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_compressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_decompressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPValidateConfig'
collect2: error: ld returned 1 exit status
make[2]: *** [tcleanupper/CMakeFiles/tdcleanup.dir/build.make:120: bin/tdcleanup] Error 1
make[1]: *** [CMakeFiles/Makefile2:843: tcleanupper/CMakeFiles/tdcleanup.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 47%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/spreadsheetviewer.cpp.o
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-#warnings' may have been intended to silence earlier diagnostics
[ 47%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_hard_light.cpp.o
[ 47%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_hard_mix.cpp.o
[ 47%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/strokesdata.cpp.o
[ 47%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/studiopaletteviewer.cpp.o
[ 47%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_lighten.cpp.o
[ 47%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_lighter_color.cpp.o
[ 47%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/styleeditor.cpp.o
[ 48%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_linear_burn.cpp.o
[ 48%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_linear_dodge.cpp.o
[ 48%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_linear_light.cpp.o
[ 48%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/styleindexlineedit.cpp.o
[ 48%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_multiply.cpp.o
[ 48%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_over.cpp.o
[ 48%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/swatchviewer.cpp.o
[ 49%] Linking CXX executable ../bin/tdconverter
[ 49%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_overlay.cpp.o
[ 49%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_pin_light.cpp.o
[ 50%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/tabbar.cpp.o
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_screen.cpp.o
[ 50%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/tdockwindows.cpp.o
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_soft_light.cpp.o
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_subtract.cpp.o
[ 50%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/tonecurvefield.cpp.o
[ 50%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/treemodel.cpp.o
[ 50%] Building CXX object toonzqt/CMakeFiles/toonzqt.dir/tselectionhandle.cpp.o
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blend_vivid_light.cpp.o
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIAppend'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPEncode'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_decompressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIDecGetRGB'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_compressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_decompress'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPIDelete'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPInitDecBufferInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureImportRGBA'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureFree'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPConfigInitInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress_bound'
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_blur.cpp.o
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_zlib_compress'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPINewDecoder'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPFreeDecBuffer'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureInitInternal'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPPictureImportRGB'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_free_compressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `libdeflate_alloc_decompressor'
/usr/sbin/ld: ../lib/tahoma2d/libimage.so: undefined reference to `WebPValidateConfig'
collect2: error: ld returned 1 exit status
make[2]: *** [tconverter/CMakeFiles/tdconverter.dir/build.make:119: bin/tdconverter] Error 1
make[1]: *** [CMakeFiles/Makefile2:908: tconverter/CMakeFiles/tdconverter.dir/all] Error 2
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_channel_selector.cpp.o
[ 50%] Building CXX object stdfx/CMakeFiles/tnzstdfx.dir/ino_common.cpp.o

Any more info I can provide?

@manongjohn
Copy link
Collaborator

@FabioLolix This is likely a similiar situation as the libdeflate issue. If you are not compiling OpenCV as part of the build process, that is likely the reason for this.

As part of OpenCV building for T2D, I compile with the following options:

cmake -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_JASPER=OFF \
      -DBUILD_JPEG=OFF \
      -DBUILD_OPENEXR=OFF \
      -DBUILD_PERF_TESTS=OFF \
      -DBUILD_PNG=OFF \
      -DBUILD_PROTOBUF=OFF \
      -DBUILD_TESTS=OFF \
      -DBUILD_TIFF=OFF \
      -DBUILD_WEBP=OFF \
      -DBUILD_ZLIB=OFF \
      -DBUILD_opencv_hdf=OFF \
      -DBUILD_opencv_java=OFF \
      -DBUILD_opencv_text=ON \
      -DOPENCV_ENABLE_NONFREE=ON \
      -DOPENCV_GENERATE_PKGCONFIG=ON \
      -DPROTOBUF_UPDATE_FILES=ON \
      -DWITH_1394=OFF \
      -DWITH_CUDA=OFF \
      -DWITH_EIGEN=ON \
      -DWITH_FFMPEG=ON \
      -DWITH_GPHOTO2=OFF \
      -DWITH_GSTREAMER=ON \
      -DWITH_JASPER=OFF \
      -DWITH_OPENEXR=ON \
      -DWITH_OPENGL=OFF \
      -DWITH_QT=OFF \
      -DWITH_TBB=ON \
      -DWITH_VTK=ON \
      -DBUILD_opencv_python2=OFF \
      -DBUILD_opencv_python3=ON 

I build OpenCV, in part to ensure LGPL compliance when packaging, and also to avoid the compile errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants