mupdf-rs icon indicating copy to clipboard operation
mupdf-rs copied to clipboard

unable to compile on MacOS

Open VirajKanse opened this issue 1 year ago • 7 comments

It seems like it is not able to locate cpp installation on my machine.

Adding the logs below:

error: failed to run custom build command for `mupdf-sys v0.4.4`

Caused by:
  process didn't exit successfully: `/Users/viraj/actix_test/target/release/build/mupdf-sys-91c4ff493db919c1/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=wrapper.h
  cargo:rerun-if-changed=wrapper.c
  OPT_LEVEL = Some(3)
  TARGET = Some(aarch64-apple-darwin)
  OUT_DIR = Some(/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
  CC_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
  CC_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
  MACOSX_DEPLOYMENT_TARGET = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
  CFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CXX_aarch64-apple-darwin
  CXX_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXX_aarch64_apple_darwin
  CXX_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-apple-darwin
  CXXFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_apple_darwin
  CXXFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/graph/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/graph/gsubgpos-context.o -c thirdparty/harfbuzz/src/graph/gsubgpos-context.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-aat-layout.o -c thirdparty/harfbuzz/src/hb-aat-layout.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-aat-map.o -c thirdparty/harfbuzz/src/hb-aat-map.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-blob.o -c thirdparty/harfbuzz/src/hb-blob.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer.o -c thirdparty/harfbuzz/src/hb-buffer.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer-verify.o -c thirdparty/harfbuzz/src/hb-buffer-verify.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer-serialize.o -c thirdparty/harfbuzz/src/hb-buffer-serialize.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11
  mkdir -p /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/ ; c++ -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -Iinclude -O3 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=15.0 -Wall -Wextra -DTOFU -DTOFU_CJK -DTOFU_NOTO -DTOFU_SYMBOL -DTOFU_EMOJI -DTOFU_SIL -MMD -MP -o /Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-common.o -c thirdparty/harfbuzz/src/hb-common.cc  -Ithirdparty/harfbuzz/src -Iinclude/mupdf -Ithirdparty/freetype/include -Iscripts/freetype -DHAVE_FALLBACK=1 -DHAVE_FREETYPE -DHAVE_OT -DHAVE_ROUND -DHAVE_UCDN -DHB_NO_MT -DHB_NO_PRAGMA_GCC_DIAGNOSTIC -w -Dhb_malloc_impl=fz_hb_malloc -Dhb_calloc_impl=fz_hb_calloc -Dhb_free_impl=fz_hb_free -Dhb_realloc_impl=fz_hb_realloc -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11

  --- stderr
  In file included from thirdparty/harfbuzz/src/hb-aat-map.cc:29:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-blob.cc:28:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-aat-layout.cc:28:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-buffer-serialize.cc:27:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-buffer-verify.cc:27:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-common.cc:29:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:
  In file included from thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:27:
  In file included from thirdparty/harfbuzz/src/graph/graph.hh:27:
  In file included from thirdparty/harfbuzz/src/graph/../hb-set.hh:31:
  thirdparty/harfbuzz/src/graph/../hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  In file included from thirdparty/harfbuzz/src/hb-buffer.cc:30:
  In file included from thirdparty/harfbuzz/src/hb-buffer.hh:33:
  thirdparty/harfbuzz/src/hb.hh:184:10: fatal error: 'cassert' file not found
    184 | #include <cassert>
        |          ^~~~~~~~~
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-blob.o] Error 1
  make: *** Waiting for unfinished jobs....
  1 error generated.
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer-verify.o] Error 1
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-common.o] Error 1
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer-serialize.o] Error 1
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-aat-map.o] Error 1
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-buffer.o] Error 1
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/graph/gsubgpos-context.o] Error 1
  1 error generated.
  make: *** [/Users/viraj/actix_test/target/release/build/mupdf-sys-1dad9a8e665dc124/out/build/thirdparty/harfbuzz/src/hb-aat-layout.o] Error 1
  thread 'main' panicked at /Users/viraj/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mupdf-sys-0.4.4/build.rs:259:9:
  Build error, exit code 2
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

VirajKanse avatar Nov 26 '24 09:11 VirajKanse

Late response but in case it helps someone else, try:

sudo rm -rf /Library/Developer/CommandLineTools/usr/include/c++

It fixed that same fatal error: 'cassert' file not found error for me.

Discussion: https://trac.macports.org/wiki/ProblemHotlist#clts16

tangent360 avatar Feb 03 '25 05:02 tangent360

@VirajKanse what features did you have enabled when you got this error?

ginnyTheCat avatar May 06 '25 03:05 ginnyTheCat

It happens with default features on on Mac OS (iMac Pro x86_64 in my case, latest Mac OS version).

  • However, it no longer fails with cacerts related messages
  • Now, errors are about climits not being found, when the fix pointed by tangent360 is not applied.
Build failure excerpt
--- stderr
  source/fitz/draw-affine.c:4027:67: warning: format specifies type 'long' but the argument has type 'int64_t' (aka 'long long') [-Wformat]
   4027 |                 fz_warn(ctx, "image too large for fixed point math: %ld x %ld", (int64_t)sw, (int64_t)sh);
        |                                                                     ~~~         ^~~~~~~~~~~
        |                                                                     %lld
  source/fitz/draw-affine.c:4027:80: warning: format specifies type 'long' but the argument has type 'int64_t' (aka 'long long') [-Wformat]
   4027 |                 fz_warn(ctx, "image too large for fixed point math: %ld x %ld", (int64_t)sw, (int64_t)sh);
        |                                                                           ~~~                ^~~~~~~~~~~
        |                                                                           %lld
  2 warnings generated.
  source/fitz/noto.c:61:9: warning: 'TOFU_NOTO' macro redefined [-Wmacro-redefined]
     61 | #define TOFU_NOTO
        |         ^
  <command line>:11:9: note: previous definition is here
     11 | #define TOFU_NOTO 0
        |         ^
  source/fitz/noto.c:62:9: warning: 'TOFU_SIL' macro redefined [-Wmacro-redefined]
     62 | #define TOFU_SIL
        |         ^
  <command line>:14:9: note: previous definition is here
     14 | #define TOFU_SIL 0
        |         ^
  source/fitz/noto.c:66:9: warning: 'TOFU_SYMBOL' macro redefined [-Wmacro-redefined]
     66 | #define TOFU_SYMBOL
        |         ^
  <command line>:12:9: note: previous definition is here
     12 | #define TOFU_SYMBOL 0
        |         ^
  source/fitz/noto.c:67:9: warning: 'TOFU_EMOJI' macro redefined [-Wmacro-redefined]
     67 | #define TOFU_EMOJI
        |         ^
  <command line>:13:9: note: previous definition is here
     13 | #define TOFU_EMOJI 0
        |         ^
  4 warnings generated.
  source/fitz/skew.c:100:12: warning: unused function 'sum_c' [-Wunused-function]
    100 | static int sum_c(const uint8_t *data)
        |            ^~~~~
  1 warning generated.
  source/fitz/tessocr.cpp:27:10: fatal error: 'climits' file not found
     27 | #include <climits>
        |          ^~~~~~~~~
  1 error generated.

yveszoundi avatar May 25 '25 17:05 yveszoundi

I don't have access to a mac currently.

Could you try to compile the following C ...

#include <limits.h>

int main() {}

... and C++ code and see whether that fails without the rm fix applied?

#include <climits>

int main() {}

The error could also come from trying to compile a C++ file using a C compiler, but then I really don't understand how the rm fix would work.

ginnyTheCat avatar May 25 '25 22:05 ginnyTheCat

Testing without rm fix

  • It works for the C code with gcc and clang.
  • It fails for the c++ code with both g++ and clang++.
c++ compilation failures
$ clang++ test.cpp
test.cpp:1:10: fatal error: 'climits' file not found
    1 | #include <climits>
      |          ^~~~~~~~~
1 error generated.

$ g++ test.cpp 
test.cpp:1:10: fatal error: 'climits' file not found
    1 | #include <climits>
      |          ^~~~~~~~~
1 error generated.

Data related to the rm fix

/Library/Developer/CommandLineTools/usr/include/c++ contains a single file in the v1 sub-directory called __cxx_version.

Here are the contents of /Library/Developer/CommandLineTools/usr/include/c++/v1/__cxx_version.

__cxx_version file contents
// -*- C++ -*-
//===--------------------------- version ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_VERSIONH
#define _LIBCPP_VERSIONH

/*
  version synopsis

Macro name                                              Value   Headers
__cpp_lib_addressof_constexpr                           201603L <memory>
__cpp_lib_allocator_traits_is_always_equal              201411L <memory> <scoped_allocator> <string>
                                                                <deque> <forward_list> <list>
                                                                <vector> <map> <set>
                                                                <unordered_map> <unordered_set>
__cpp_lib_any                                           201606L <any>
__cpp_lib_apply                                         201603L <tuple>
__cpp_lib_array_constexpr                               201603L <iterator> <array>
__cpp_lib_as_const                                      201510L <utility>
__cpp_lib_atomic_is_always_lock_free                    201603L <atomic>
__cpp_lib_atomic_ref                                    201806L <atomic>
__cpp_lib_bind_front                                    201811L <functional>
__cpp_lib_bit_cast                                      201806L <bit>
__cpp_lib_bool_constant                                 201505L <type_traits>
__cpp_lib_boyer_moore_searcher                          201603L <functional>
__cpp_lib_byte                                          201603L <cstddef>
__cpp_lib_char8_t                                       201811L <atomic> <filesystem> <istream>
                                                                <limits> <locale> <ostream>
                                                                <string> <string_view>
__cpp_lib_chrono                                        201611L <chrono>
__cpp_lib_chrono_udls                                   201304L <chrono>
__cpp_lib_clamp                                         201603L <algorithm>
__cpp_lib_complex_udls                                  201309L <complex>
__cpp_lib_concepts                                      201806L <concepts>
__cpp_lib_constexpr_misc                                201811L <array> <functional> <iterator>
                                                                <string_view> <tuple> <utility>
__cpp_lib_constexpr_swap_algorithms                     201806L <algorithm>
__cpp_lib_destroying_delete                             201806L <new>
__cpp_lib_enable_shared_from_this                       201603L <memory>
__cpp_lib_endian                                        201907L <bit>
__cpp_lib_erase_if                                      201811L <string> <deque> <forward_list>
                                                                <list> <vector> <map>
                                                                <set> <unordered_map> <unordered_set>
__cpp_lib_exchange_function                             201304L <utility>
__cpp_lib_execution                                     201603L <execution>
__cpp_lib_filesystem                                    201703L <filesystem>
__cpp_lib_gcd_lcm                                       201606L <numeric>
__cpp_lib_generic_associative_lookup                    201304L <map> <set>
__cpp_lib_generic_unordered_lookup                      201811L <unordered_map> <unordered_set>
__cpp_lib_hardware_interference_size                    201703L <new>
__cpp_lib_has_unique_object_representations             201606L <type_traits>
__cpp_lib_hypot                                         201603L <cmath>
__cpp_lib_incomplete_container_elements                 201505L <forward_list> <list> <vector>
__cpp_lib_integer_sequence                              201304L <utility>
__cpp_lib_integral_constant_callable                    201304L <type_traits>
__cpp_lib_interpolate                                   201902L <numeric>
__cpp_lib_invoke                                        201411L <functional>
__cpp_lib_is_aggregate                                  201703L <type_traits>
__cpp_lib_is_constant_evaluated                         201811L <type_traits>
__cpp_lib_is_final                                      201402L <type_traits>
__cpp_lib_is_invocable                                  201703L <type_traits>
__cpp_lib_is_null_pointer                               201309L <type_traits>
__cpp_lib_is_swappable                                  201603L <type_traits>
__cpp_lib_launder                                       201606L <new>
__cpp_lib_list_remove_return_type                       201806L <forward_list> <list>
__cpp_lib_logical_traits                                201510L <type_traits>
__cpp_lib_make_from_tuple                               201606L <tuple>
__cpp_lib_make_reverse_iterator                         201402L <iterator>
__cpp_lib_make_unique                                   201304L <memory>
__cpp_lib_map_try_emplace                               201411L <map>
__cpp_lib_math_special_functions                        201603L <cmath>
__cpp_lib_memory_resource                               201603L <memory_resource>
__cpp_lib_node_extract                                  201606L <map> <set> <unordered_map>
                                                                <unordered_set>
__cpp_lib_nonmember_container_access                    201411L <iterator> <array> <deque>
                                                                <forward_list> <list> <map>
                                                                <regex> <set> <string>
                                                                <unordered_map> <unordered_set> <vector>
__cpp_lib_not_fn                                        201603L <functional>
__cpp_lib_null_iterators                                201304L <iterator>
__cpp_lib_optional                                      201606L <optional>
__cpp_lib_parallel_algorithm                            201603L <algorithm> <numeric>
__cpp_lib_quoted_string_io                              201304L <iomanip>
__cpp_lib_ranges                                        201811L <algorithm> <functional> <iterator>
                                                                <memory> <ranges>
__cpp_lib_raw_memory_algorithms                         201606L <memory>
__cpp_lib_result_of_sfinae                              201210L <functional> <type_traits>
__cpp_lib_robust_nonmodifying_seq_ops                   201304L <algorithm>
__cpp_lib_sample                                        201603L <algorithm>
__cpp_lib_scoped_lock                                   201703L <mutex>
__cpp_lib_shared_mutex                                  201505L <shared_mutex>
__cpp_lib_shared_ptr_arrays                             201611L <memory>
__cpp_lib_shared_ptr_weak_type                          201606L <memory>
__cpp_lib_shared_timed_mutex                            201402L <shared_mutex>
__cpp_lib_string_udls                                   201304L <string>
__cpp_lib_string_view                                   201606L <string> <string_view>
__cpp_lib_three_way_comparison                          201711L <compare>
__cpp_lib_to_chars                                      201611L <utility>
__cpp_lib_transformation_trait_aliases                  201304L <type_traits>
__cpp_lib_transparent_operators                         201510L <functional>
                                                        201210L // C++14
__cpp_lib_tuple_element_t                               201402L <tuple>
__cpp_lib_tuples_by_type                                201304L <utility> <tuple>
__cpp_lib_type_trait_variable_templates                 201510L <type_traits>
__cpp_lib_uncaught_exceptions                           201411L <exception>
__cpp_lib_unordered_map_try_emplace                     201411L <unordered_map>
__cpp_lib_variant                                       201606L <variant>
__cpp_lib_void_t                                        201411L <type_traits>

*/

#include <__config>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

#if _LIBCPP_STD_VER > 11
# define __cpp_lib_chrono_udls                          201304L
# define __cpp_lib_complex_udls                         201309L
# define __cpp_lib_exchange_function                    201304L
# define __cpp_lib_generic_associative_lookup           201304L
# define __cpp_lib_integer_sequence                     201304L
# define __cpp_lib_integral_constant_callable           201304L
# define __cpp_lib_is_final                             201402L
# define __cpp_lib_is_null_pointer                      201309L
# define __cpp_lib_make_reverse_iterator                201402L
# define __cpp_lib_make_unique                          201304L
# define __cpp_lib_null_iterators                       201304L
# define __cpp_lib_quoted_string_io                     201304L
# define __cpp_lib_result_of_sfinae                     201210L
# define __cpp_lib_robust_nonmodifying_seq_ops          201304L
# if !defined(_LIBCPP_HAS_NO_THREADS)
#   define __cpp_lib_shared_timed_mutex                 201402L
# endif
# define __cpp_lib_string_udls                          201304L
# define __cpp_lib_transformation_trait_aliases         201304L
# define __cpp_lib_transparent_operators                201210L
# define __cpp_lib_tuple_element_t                      201402L
# define __cpp_lib_tuples_by_type                       201304L
#endif

#if _LIBCPP_STD_VER > 14
# if !defined(_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF)
#   define __cpp_lib_addressof_constexpr                201603L
# endif
# define __cpp_lib_allocator_traits_is_always_equal     201411L
# define __cpp_lib_any                                  201606L
# define __cpp_lib_apply                                201603L
# define __cpp_lib_array_constexpr                      201603L
# define __cpp_lib_as_const                             201510L
# if !defined(_LIBCPP_HAS_NO_THREADS)
#   define __cpp_lib_atomic_is_always_lock_free         201603L
# endif
# define __cpp_lib_bool_constant                        201505L
// # define __cpp_lib_boyer_moore_searcher                 201603L
# define __cpp_lib_byte                                 201603L
# define __cpp_lib_chrono                               201611L
# define __cpp_lib_clamp                                201603L
# define __cpp_lib_enable_shared_from_this              201603L
// # define __cpp_lib_execution                            201603L
# define __cpp_lib_filesystem                           201703L
# define __cpp_lib_gcd_lcm                              201606L
# define __cpp_lib_hardware_interference_size           201703L
# if defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
#   define __cpp_lib_has_unique_object_representations  201606L
# endif
# define __cpp_lib_hypot                                201603L
# define __cpp_lib_incomplete_container_elements        201505L
# define __cpp_lib_invoke                               201411L
# if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
#   define __cpp_lib_is_aggregate                       201703L
# endif
# define __cpp_lib_is_invocable                         201703L
# define __cpp_lib_is_swappable                         201603L
# define __cpp_lib_launder                              201606L
# define __cpp_lib_logical_traits                       201510L
# define __cpp_lib_make_from_tuple                      201606L
# define __cpp_lib_map_try_emplace                      201411L
// # define __cpp_lib_math_special_functions               201603L
// # define __cpp_lib_memory_resource                      201603L
# define __cpp_lib_node_extract                         201606L
# define __cpp_lib_nonmember_container_access           201411L
# define __cpp_lib_not_fn                               201603L
# define __cpp_lib_optional                             201606L
// # define __cpp_lib_parallel_algorithm                   201603L
# define __cpp_lib_raw_memory_algorithms                201606L
# define __cpp_lib_sample                               201603L
# define __cpp_lib_scoped_lock                          201703L
# if !defined(_LIBCPP_HAS_NO_THREADS)
#   define __cpp_lib_shared_mutex                       201505L
# endif
// # define __cpp_lib_shared_ptr_arrays                    201611L
# define __cpp_lib_shared_ptr_weak_type                 201606L
# define __cpp_lib_string_view                          201606L
// # define __cpp_lib_to_chars                             201611L
# undef  __cpp_lib_transparent_operators
# define __cpp_lib_transparent_operators                201510L
# define __cpp_lib_type_trait_variable_templates        201510L
# define __cpp_lib_uncaught_exceptions                  201411L
# define __cpp_lib_unordered_map_try_emplace            201411L
# define __cpp_lib_variant                              201606L
# define __cpp_lib_void_t                               201411L
#endif

#if _LIBCPP_STD_VER > 17
# if !defined(_LIBCPP_HAS_NO_THREADS)
// #   define __cpp_lib_atomic_ref                         201806L
# endif
// # define __cpp_lib_bind_front                           201811L
// # define __cpp_lib_bit_cast                             201806L
# if !defined(_LIBCPP_NO_HAS_CHAR8_T)
#   define __cpp_lib_char8_t                            201811L
# endif
// # define __cpp_lib_concepts                             201806L
// # define __cpp_lib_constexpr_misc                       201811L
// # define __cpp_lib_constexpr_swap_algorithms            201806L
# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
#   define __cpp_lib_destroying_delete                  201806L
# endif
# define __cpp_lib_endian                               201907L
# define __cpp_lib_erase_if                             201811L
// # define __cpp_lib_generic_unordered_lookup             201811L
# define __cpp_lib_interpolate                          201902L
# if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
#   define __cpp_lib_is_constant_evaluated              201811L
# endif
// # define __cpp_lib_list_remove_return_type              201806L
// # define __cpp_lib_ranges                               201811L
// # define __cpp_lib_three_way_comparison                 201711L
#endif

#endif // _LIBCPP_VERSIONH

yveszoundi avatar May 26 '25 00:05 yveszoundi

I don't know a lot about macos but other people online recommend using sudo xcode-select -s /Library/Developer/CommandLineTools to specify the active developer directory. I'm not sure whether the build.rs could try discovering a C++ toolchain on it's own (or whether that's sth cc should already be doing) or whether this sth users have to fix by themselves (like installing visual c++ on windows).

ginnyTheCat avatar May 26 '25 04:05 ginnyTheCat

A simple note in the main README would suffice in my opinion, as I don't think that there's anything wrong with the build.

  • I did some more investigations and lots of people seem to be having similar issues and don't know how to fix it
  • Apparently that c++ folder was a left-over from a bad installer (I've had this Mac since 2017) and there are 2 simple options to fix it
    • If it exists, just delete the folder /Library/Developer/CommandLineTools/usr/include/c++/
    • Otherwise, users can perform a clean installation of command-line tools as follow:
      • sudo rm -rf /Library/Developer/CommandLineTools/
      • xcode-select --install

After a clean reinstall, that bogus c++ folder is no longer present on my system

$ ls /Library/Developer/CommandLineTools/usr/include/ 
FlexLexer.h             module.modulemap        swift

yveszoundi avatar May 26 '25 15:05 yveszoundi