AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.58k stars 203 forks source link

Not able to build static build on amazon linux 2023 #2158

Closed dhruv-nudge closed 6 months ago

dhruv-nudge commented 6 months ago

I followed all the required steps and was able to build on my mac, but when I tried on amazon linux 2, I was not able to.

I am getting this error

cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_JPEG=LOCAL -DAVIF_ZLIBPNG=LOCAL -DAVIF_BUILD_APPS=ON
-- Checking for module 'libyuv'
--   Package 'libyuv', required by 'virtual:world', not found
-- libavif: libyuv not found; libyuv-based fast paths disabled.
-- Checking for module 'libsharpyuv'
--   Package 'libsharpyuv', required by 'virtual:world', not found
-- libavif: libsharpyuv not found
-- libavif: Enabling warnings for GCC
-- Checking for module 'aom'
--   Package 'aom', required by 'virtual:world', not found
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find aom (missing: AOM_LIBRARY AOM_LIBRARIES AOM_INCLUDE_DIR)
  (found version "")
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/Findaom.cmake:32 (find_package_handle_standard_args)
  CMakeLists.txt:463 (find_package)

i have already ran these commands in ext dir

./aom.cmd
./libyuv.cmd
./libsharpyuv.cmd
./libjpeg.cmd
./zlibpng.cmd
wantehchang commented 6 months ago

Hi @dhruv-nudge,

Your cmake command line looks correct. I just repeated your steps in a version of Debian Linux. I can't reproduce the cmake errors. I tested the tip of the main branch of libavif.

What version of libavif are you using?

What is the output of cmake --version?

Note: Unrelated to your cmake problem: I recommend running the ./dav1d.cmd command in the ext directory and adding -DAVIF_CODEC_DAV1D=LOCAL to your cmake command line. The dav1d AV1 decoder is faster than the AV1 decoder in libaom.

dhruv-nudge commented 6 months ago

hey I am using 1.0.3 like in README

cmake version 3.22.2

when runngin ./libyuv.cmd, I am getting this in logs

-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 

and I get this when I run ./libsharpyuv.cmd

fatal: destination path 'libwebp' already exists and is not an empty directory.
HEAD is now at e2c85878 Add an initializer for the SharpYuvOptions struct.
mkdir: cannot create directory ‘build’: File exists
-- Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OPENGL_INCLUDE_DIR) 
-- Adding -lm flag.
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 
-- TIFF is disabled when statically linking.
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR) 
-- Performing Test WEBP_HAVE_FLAG_SSE41
-- Performing Test WEBP_HAVE_FLAG_SSE41 - Failed
-- Performing Test WEBP_HAVE_FLAG_SSE41
-- Performing Test WEBP_HAVE_FLAG_SSE41 - Failed
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Failed
-- Performing Test WEBP_HAVE_FLAG_SSE2
-- Performing Test WEBP_HAVE_FLAG_SSE2 - Failed
-- Performing Test WEBP_HAVE_FLAG_SSE2
-- Performing Test WEBP_HAVE_FLAG_SSE2 - Failed
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Failed
-- Performing Test WEBP_HAVE_FLAG_MIPS32
-- Performing Test WEBP_HAVE_FLAG_MIPS32 - Failed
-- Performing Test WEBP_HAVE_FLAG_MIPS32
-- Performing Test WEBP_HAVE_FLAG_MIPS32 - Failed
-- Performing Test WEBP_HAVE_FLAG_MIPS_DSP_R2
-- Performing Test WEBP_HAVE_FLAG_MIPS_DSP_R2 - Failed
-- Performing Test WEBP_HAVE_FLAG_MIPS_DSP_R2
-- Performing Test WEBP_HAVE_FLAG_MIPS_DSP_R2 - Failed
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Failed
-- Performing Test WEBP_HAVE_FLAG_NEON
-- Performing Test WEBP_HAVE_FLAG_NEON - Success
-- Performing Test WEBP_HAVE_FLAG_MSA
-- Performing Test WEBP_HAVE_FLAG_MSA - Failed
-- Performing Test WEBP_HAVE_FLAG_MSA
-- Performing Test WEBP_HAVE_FLAG_MSA - Failed
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Failed
-- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ec2-user/libavif/ext/libwebp/build

do we need to install more libraries before following all the steps?

dhruv-nudge commented 6 months ago

I tried with version 1.0.4 of libavif as well in ubuntu 22, but still getting errors

-- libavif: libyuv not found; libyuv-based fast paths disabled.
-- libavif: libsharpyuv not found
-- libavif: Enabling warnings for GCC
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find aom (missing: AOM_LIBRARY AOM_LIBRARIES AOM_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/Findaom.cmake:32 (find_package_handle_standard_args)
  CMakeLists.txt:463 (find_package)
wantehchang commented 6 months ago

Thanks for the libavif versions. With version 1.0.x, you need to use the old-style options to enable libaom, libyuv, etc. The README file you read is apparently from the tip of the main branch, so it describes the new-style options. This unfortunate discrepancy will be fixed when we create the 1.1.0 release.

When using version 1.0.x, change

-DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_JPEG=LOCAL -DAVIF_ZLIBPNG=LOCAL

to

-DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_LOCAL_LIBYUV=ON -DAVIF_LOCAL_LIBSHARPYUV=ON -DAVIF_LOCAL_JPEG=ON -DAVIF_LOCAL_ZLIBPNG=ON

Note that the old-stype options will continue to be supported for a while.

As for the error (or rather, warning) messages when you ran ./libyuv.cmd and ./libsharpyuv.cmd, those libraries are apparently for optional features in libyuv and libsharpyuv. If those libraries are not installed on your system, the optional features are not built. If you can build libavif successfully, it means libavif does not use those optional features of libyuv and libsharpyuv. In that case you can safely ignore those error messages.

Finally, this error message from ./libsharpyuv.cmd

fatal: destination path 'libwebp' already exists and is not an empty directory.

can be fixed by removing the libwebp directory before you run ./libsharpyuv.cmd again.

dhruv-nudge commented 6 months ago

@wantehchang thanks a lot, it worked!

dhruv-nudge commented 6 months ago

I also wanted to just confirm are those optional libraries important to convert all kinds of images to avif? I want to convert all formats (png, jpg, giff, webp, tiff and etc) to avif. I will not convert from avif to any other format.

wantehchang commented 6 months ago

Hi @dhruv-nudge

I can only answer the question for libyuv: libavif doesn't use the optional feature of libyuv that requires libjpeg.

The question is harder to answer for libsharpyuv. libsharpyuv is a component of libwebp. I believe we are running the cmake command to configure the enture libwebp, and then only build the libsharpyuv component. Intuitively I would expect that those optional features that require additional libraries to be installed on the system are outside libsharpyuv, but I didn't spend the time verifying that.

wantehchang commented 6 months ago

Also, the avifenc command can only convert PNG and JPEG inputs to AVIF. It cannot convert GIF, WebP, and TIFF to AVIF. I think there is a feature request for avifenc to support additional input image formats. You can look into using ffmpeg or ImageMagick to do that.

jzern commented 6 months ago

Intuitively I would expect that those optional features that require additional libraries to be installed on the system are outside libsharpyuv, but I didn't spend the time verifying that.

Yes, that is true. The support libraries (jpeg, tiff, png, gif) are only used by the examples like cwebp and dwebp.