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

Building dav1d in a vendored build fails for me on Fedora Linux #477

Open
nightmareci opened this issue Nov 8, 2024 · 0 comments
Open

Comments

@nightmareci
Copy link

While I was trying to do a vendored build of SDL3 SDL_image on Fedora Linux, dav1d was failing to build, due to posix_memalign() not being defined, despite the build system setting HAVE_POSIX_MEMALIGN; it seems the check_symbol_exists(posix_memalign "stdlib.h" HAVE_POSIX_MEMALIGN) line is finding posix_memalign(), despite posix_memalign() breaking the build. Turns out, per the Linux documentation, you need to define _POSIX_C_SOURCE to 200112L or higher for posix_memalign(). I made the following change to dav1d's CMakeLists.txt, then dav1d built successfully:

# The WIN32 part is already in the CMakeLists.txt file, it's just here to hint where my change was made
# I'm not sure if checking only UNIX is correct, but it at least works for me on Fedora Linux
if(WIN32)
  add_compile_definitions(
    _WIN32_WINNT=0x0601
    UNICODE=1
    _UNICODE=1
    __USE_MINGW_ANSI_STDIO=1
    _CRT_DECLARE_NONSTDC_NAMES=1
  )
  check_symbol_exists(fseeko stdio.h STDIO_H_PROVIDES_FSEEKO)
  if(STDIO_H_PROVIDES_FSEEKO)
    add_compile_definitions(_FILE_OFFSET_BITS=64)
  else()
    add_compile_definitions(fseeko=_fseeki64 ftello=_ftelli64)
  endif()
elseif(UNIX)
  add_compile_definitions(
    _POSIX_C_SOURCE=200112L
  )
endif()

For whatever reason, dav1d successfully builds for SDL2 SDL_image, despite the SDL2 SDL_image's vendored dav1d CMakeLists.txt not defining _POSIX_C_SOURCE anywhere, maybe _POSIX_C_SOURCE is getting defined somewhere else. For the sake of strict correctness, it may be appropriate to define _POSIX_C_SOURCE for SDL2 SDL_image's vendored dav1d as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant