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

macOS build error - fontconfig.h file not found #135

Open
joewiz opened this issue Dec 9, 2021 · 8 comments
Open

macOS build error - fontconfig.h file not found #135

joewiz opened this issue Dec 9, 2021 · 8 comments
Assignees
Labels
bug Something isn't working macos-specific

Comments

@joewiz
Copy link

joewiz commented Dec 9, 2021

After performing the build steps described in the README, I encountered the following error with the make command:

joe@choskimac-iii workspace % git clone https://github.com/kermitt2/pdfalto.git && cd pdfalto
Cloning into 'pdfalto'...
remote: Enumerating objects: 2905, done.
remote: Counting objects: 100% (572/572), done.
remote: Compressing objects: 100% (327/327), done.
remote: Total 2905 (delta 346), reused 451 (delta 239), pack-reused 2333
Receiving objects: 100% (2905/2905), 62.02 MiB | 10.84 MiB/s, done.
Resolving deltas: 100% (1347/1347), done.

joe@choskimac-iii pdfalto % git submodule update --init --recursive
Submodule 'xpdf-4.03' (git@github.com:kermitt2/xpdf-4.03.git) registered for path 'xpdf-4.03'
Cloning into '/Users/joe/workspace/pdfalto/xpdf-4.03'...
Submodule path 'xpdf-4.03': checked out 'd1d1fe28e267911a8e5a8b51b9ebde250a7d70e7'

joe@choskimac-iii pdfalto % cmake .
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found fontconfig
Using macos settings.
++ 64 bit architecture
CMake Deprecation Warning at xpdf-4.03/CMakeLists.txt:11 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Looking for mkstemp
-- Looking for mkstemp - found
-- Looking for mkstemps
-- Looking for mkstemps - found
-- Looking for popen
-- Looking for popen - found
-- Performing Test HAVE_STD_SORT
-- Performing Test HAVE_STD_SORT - Success
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for fseek64
-- Looking for fseek64 - not found
-- Looking for _fseeki64
-- Looking for _fseeki64 - not found
-- Found FreeType (old-style includes): /Users/joe/workspace/pdfalto/libs/freetype/mac/64/libfreetype.a
-- Found fontconfig
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/joe/workspace/pdfalto

joe@choskimac-iii pdfalto % make
[  1%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/AcroForm.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Annot.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Array.cc.o
[  3%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFont.cc.o
[  4%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFontTables.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Catalog.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CharCodeToUnicode.cc.o
[  6%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CMap.cc.o
[  7%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Decrypt.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Dict.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/DisplayState.cc.o
[  9%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Error.cc.o
[ 10%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/FontEncodingTables.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Function.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Gfx.cc.o
[ 12%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxFont.cc.o
[ 13%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxState.cc.o
[ 14%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o
/Users/joe/workspace/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:27:12: fatal error: 'fontconfig/fontconfig.h' file not found
#  include <fontconfig/fontconfig.h>
           ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o] Error 1
make[1]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/all] Error 2
make: *** [all] Error 2

Could anyone suggest a workaround for this issue?

I'm running macOS 12 on an Intel-based iMac, with the following versions of the required dependencies:

joe@choskimac-iii pdfalto % clang -v
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

joe@choskimac-iii pdfalto % gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

joe@choskimac-iii pdfalto % cmake --version
cmake version 3.22.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

joe@choskimac-iii pdfalto % wget -V
GNU Wget 1.21.2 built on darwin20.4.0.

I'd be happy to provide any other needed information.

@kermitt2
Copy link
Owner

kermitt2 commented Dec 9, 2021

Hi @joewiz !

If I remember well, on mac fontconfig/fontconfig.h is installed under /usr/local/include

but for some reasons, the compiler you use is not looking at /usr/local/include - this is a mac specific problem, because it's normally a standard place for finder headers - it's not the fault of cmake it's related to the macos xcode/SDK I think.

The solution then is to add -I/usr/local/include as compiler option.

@kermitt2
Copy link
Owner

kermitt2 commented Dec 9, 2021

The solution then is to add -I/usr/local/include as compiler option.

so I think adding to CMakeLists.txt the line:

set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include")

I also saw this possible solution: https://stackoverflow.com/a/26404710

note: I am not working on Mac, I can't reproduce/test/solution for the issue but I am aware of it !

@joewiz
Copy link
Author

joewiz commented Dec 9, 2021

@kermitt2 Thanks so much! I tried making your suggested change to CMakeLists.txt, but the same error appeared, even though I have the XCode Command Line Tools installed (via xcode-select --install). One of the other answers to the question you linked to did work, though: https://stackoverflow.com/a/30895165/659732. Specifically, here's what I did:

joe@choskimac-iii pdfalto % export C_INCLUDE_PATH=/usr/local/include

joe@choskimac-iii pdfalto % export CPLUS_INCLUDE_PATH=/usr/local/include

joe@choskimac-iii pdfalto % make                                        
-- Found fontconfig
Using macos settings.
++ 64 bit architecture
CMake Deprecation Warning at xpdf-4.03/CMakeLists.txt:11 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Found FreeType (old-style includes): /Users/joe/workspace/pdfalto/libs/freetype/mac/64/libfreetype.a
-- Found fontconfig
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/joe/workspace/pdfalto
Consolidate compiler generated dependencies of target xpdf
[  1%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o
In file included from /Users/joe/workspace/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:70:
/Users/joe/workspace/pdfalto/xpdf-4.03/xpdf/UnicodeToUnicodeFontRules.h:28:10: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        {"AdvTT3f84ef53", 61550, advtt3f84ef53}
         ^
1 warning generated.
[  1%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/JArithmeticDecoder.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/JBIG2Stream.cc.o
[  3%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/JPXStream.cc.o
[  4%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Lexer.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Link.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/NameToCharCode.cc.o
[  6%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Object.cc.o
[  7%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/OptionalContent.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Outline.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/OutputDev.cc.o
[  9%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Page.cc.o
[ 10%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Parser.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/PDFCore.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/PDF417Barcode.cc.o
[ 12%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/PDFDoc.cc.o
[ 13%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/PDFDocEncoding.cc.o
[ 14%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/PSTokenizer.cc.o
[ 14%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/SecurityHandler.cc.o
[ 15%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Stream.cc.o
[ 16%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/TextString.cc.o
[ 17%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/UnicodeMap.cc.o
[ 17%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/UnicodeRemapping.cc.o
[ 18%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/UnicodeTypeTable.cc.o
[ 19%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/UTF8.cc.o
[ 20%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/XFAScanner.cc.o
[ 20%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/XRef.cc.o
[ 21%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Zoox.cc.o
[ 22%] Linking CXX static library ../build/xpdf/lib/libxpdf.a
[ 35%] Built target xpdf
[ 35%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/FixedPoint.cc.o
[ 36%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/GHash.cc.o
[ 37%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/GList.cc.o
[ 38%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/GString.cc.o
[ 38%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/gfile.cc.o
[ 39%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/gmem.cc.o
[ 40%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/gmempp.cc.o
[ 41%] Building C object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/parseargs.c.o
[ 41%] Building CXX object xpdf-4.03/goo/CMakeFiles/goo_objs.dir/Trace.cc.o
[ 41%] Built target goo_objs
[ 42%] Linking CXX static library libgoo.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(FixedPoint.cc.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(gmempp.cc.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(Trace.cc.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(FixedPoint.cc.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(gmempp.cc.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libgoo.a(Trace.cc.o) has no symbols
[ 42%] Built target goo
[ 43%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiBase.cc.o
[ 44%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiEncodings.cc.o
[ 45%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiIdentifier.cc.o
[ 45%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiTrueType.cc.o
[ 46%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiType1.cc.o
[ 47%] Building CXX object xpdf-4.03/fofi/CMakeFiles/fofi_objs.dir/FoFiType1C.cc.o
[ 47%] Built target fofi_objs
[ 47%] Linking CXX static library libfofi.a
[ 47%] Built target fofi
[ 48%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/Splash.cc.o
[ 48%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashBitmap.cc.o
[ 49%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashClip.cc.o
[ 50%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFTFont.cc.o
[ 51%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFTFontEngine.cc.o
[ 52%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFTFontFile.cc.o
[ 52%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFont.cc.o
[ 53%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFontEngine.cc.o
[ 54%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFontFile.cc.o
[ 55%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashFontFileID.cc.o
[ 55%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashPath.cc.o
[ 56%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashPattern.cc.o
[ 57%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashScreen.cc.o
[ 58%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashState.cc.o
[ 58%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashXPath.cc.o
[ 59%] Building CXX object xpdf-4.03/splash/CMakeFiles/splash_objs.dir/SplashXPathScanner.cc.o
[ 59%] Built target splash_objs
[ 60%] Linking CXX static library libsplash.a
[ 60%] Built target splash
[ 61%] Building CXX object CMakeFiles/pdfalto.dir/src/AnnotsXrce.cc.o
[ 62%] Building CXX object CMakeFiles/pdfalto.dir/src/ConstantsUtils.cc.o
[ 63%] Building CXX object CMakeFiles/pdfalto.dir/src/ConstantsXML.cc.o
[ 63%] Building CXX object CMakeFiles/pdfalto.dir/src/Parameters.cc.o
[ 64%] Building CXX object CMakeFiles/pdfalto.dir/src/PDFDocXrce.cc.o
[ 65%] Building C object CMakeFiles/pdfalto.dir/src/whereami.c.o
[ 66%] Building CXX object CMakeFiles/pdfalto.dir/src/pdfalto.cc.o
[ 66%] Building CXX object CMakeFiles/pdfalto.dir/src/XmlAltoOutputDev.cc.o
/Users/joe/workspace/pdfalto/src/XmlAltoOutputDev.cc:4793:34: warning: equality comparison result unused [-Wunused-comparison]
                        nextWord == NULL;
                        ~~~~~~~~~^~~~~~~
/Users/joe/workspace/pdfalto/src/XmlAltoOutputDev.cc:4793:34: note: use '=' to turn this equality comparison into an assignment
                        nextWord == NULL;
                                 ^~
                                 =
1 warning generated.
[ 67%] Linking CXX executable pdfalto
clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
[ 67%] Built target pdfalto
[ 68%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/AcroForm.cc.o
[ 68%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Annot.cc.o
[ 69%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Array.cc.o
[ 70%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/BuiltinFont.cc.o
[ 71%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/BuiltinFontTables.cc.o
[ 71%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Catalog.cc.o
[ 72%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/CharCodeToUnicode.cc.o
[ 73%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/CMap.cc.o
[ 74%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Decrypt.cc.o
[ 75%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Dict.cc.o
[ 75%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Error.cc.o
[ 76%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/FontEncodingTables.cc.o
[ 77%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Function.cc.o
[ 78%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Gfx.cc.o
[ 78%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/GfxFont.cc.o
[ 79%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/GfxState.cc.o
[ 80%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/GlobalParams.cc.o
In file included from /Users/joe/workspace/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:70:
/Users/joe/workspace/pdfalto/xpdf-4.03/xpdf/UnicodeToUnicodeFontRules.h:28:10: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        {"AdvTT3f84ef53", 61550, advtt3f84ef53}
         ^
1 warning generated.
[ 81%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/JArithmeticDecoder.cc.o
[ 81%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/JBIG2Stream.cc.o
[ 82%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/JPXStream.cc.o
[ 83%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Lexer.cc.o
[ 84%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Link.cc.o
[ 84%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/NameToCharCode.cc.o
[ 85%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Object.cc.o
[ 86%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/OptionalContent.cc.o
[ 87%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Outline.cc.o
[ 87%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/OutputDev.cc.o
[ 88%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Page.cc.o
[ 89%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Parser.cc.o
[ 90%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/PDF417Barcode.cc.o
[ 90%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/PDFDoc.cc.o
[ 91%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/PDFDocEncoding.cc.o
[ 92%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/PSTokenizer.cc.o
[ 93%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/SecurityHandler.cc.o
[ 93%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Stream.cc.o
[ 94%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/TextString.cc.o
[ 95%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/UnicodeMap.cc.o
[ 96%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/UnicodeRemapping.cc.o
[ 96%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/UnicodeTypeTable.cc.o
[ 97%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/UTF8.cc.o
[ 98%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/XFAScanner.cc.o
[ 99%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/XRef.cc.o
[100%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf_objs.dir/Zoox.cc.o
[100%] Built target xpdf_objs

After that, I'm able to call pdfalto:

joe@choskimac-iii pdfalto % ./pdfalto
pdfalto version 0.5
Usage: pdfalto [options] <PDF-file> [<xml-file>]
  -f <int>                      : first page to convert
  -l <int>                      : last page to convert
  -verbose                      : display pdf attributes
  -noImage                      : do not extract Images (Bitmap and Vectorial)
  -noImageInline                : deprecated
  -outline                      : create an outline file xml
  -annotation                   : create an annotations file xml
  -noLineNumbers                : do not output line numbers added in manuscript-style textual documents
  -readingOrder                 : blocks follow the reading order
  -noText                       : do not extract textual objects (might be useful, but non-valid ALTO)
  -charReadingOrderAttr         : include TYPE attribute to String elements to indicate right-to-left reading order (might be useful, but non-valid ALTO)
  -fullFontName                 : fonts names are not normalized
  -nsURI <string>               : add the specified namespace URI
  -opw <string>                 : owner password (for encrypted files)
  -upw <string>                 : user password (for encrypted files)
  -filesLimit <int>             : limit of asset files be extracted
  -q                            : don't print any messages or errors
  -v                            : print version info
  -h                            : print usage information
  -help                         : print usage information
  --help                        : print usage information
  -?                            : print usage information

Thank you so much! I've already converted my first PDF to ALTO with the utility, and the results look great (and much more usable than pdf2xml's output). Much appreciated!

@joewiz joewiz closed this as completed Dec 9, 2021
@kermitt2
Copy link
Owner

Thank you for the feedback !

I take the freedom to reopen the issue, I will try to add a MacOS-specific fix directly in the CMakeList file because this is a recurring issue now.

I also put a reference to this issue in the readme for MacOS users.

@kermitt2 kermitt2 reopened this Dec 10, 2021
@kermitt2 kermitt2 self-assigned this Dec 10, 2021
@kermitt2 kermitt2 added bug Something isn't working macos-specific labels Dec 10, 2021
matthieu-perso added a commit to matthieu-perso/xpdf-4.03 that referenced this issue Jan 25, 2022
**Context**
As per the [following issue](kermitt2/pdfalto#135), Mac users have been repeatedly encountering issues with `fontconfig.h` while running the `make` command. The proposed solution in the issue thread was to change the CMakeLists file. 
**Changes**
This PR proposes another solution, which is to detect the Apple OS from the compiler macros, thereby changing the path to `fontconfig` based on the user's OS directly in the file where fontconfig is included.
@marja-w
Copy link

marja-w commented May 6, 2022

Hello, I am using Windows 10 and receive the same error. I am using cygwin for creating the Makefile with cmake. I get the same error when running the make command:

$ make
[  1%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/AcroForm.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Annot.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Array.cc.o
[  3%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFont.cc.o
[  4%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFontTables.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Catalog.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CharCodeToUnicode.cc.o
[  6%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CMap.cc.o
[  7%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Decrypt.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Dict.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/DisplayState.cc.o
[  9%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Error.cc.o
[ 10%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/FontEncodingTables.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Function.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Gfx.cc.o
[ 12%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxFont.cc.o
[ 13%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxState.cc.o
[ 14%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o
C:/Users/admin/PycharmProjects/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:27:12: fatal error: fontconfig/fontconfig.h: No such file or directory
 #  include <fontconfig/fontconfig.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/build.make:314: xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:362: xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I tried the solutions proposed, like adding the line to the CMakeLists.txt file or the solution that worked for @joewiz, but I still receive the same error.

@MIracleyin
Copy link

Hello, I am using Windows 10 and receive the same error. I am using cygwin for creating the Makefile with cmake. I get the same error when running the make command:

$ make
[  1%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/AcroForm.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Annot.cc.o
[  2%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Array.cc.o
[  3%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFont.cc.o
[  4%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/BuiltinFontTables.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Catalog.cc.o
[  5%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CharCodeToUnicode.cc.o
[  6%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/CMap.cc.o
[  7%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Decrypt.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Dict.cc.o
[  8%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/DisplayState.cc.o
[  9%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Error.cc.o
[ 10%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/FontEncodingTables.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Function.cc.o
[ 11%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/Gfx.cc.o
[ 12%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxFont.cc.o
[ 13%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GfxState.cc.o
[ 14%] Building CXX object xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o
C:/Users/admin/PycharmProjects/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:27:12: fatal error: fontconfig/fontconfig.h: No such file or directory
 #  include <fontconfig/fontconfig.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/build.make:314: xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:362: xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I tried the solutions proposed, like adding the line to the CMakeLists.txt file or the solution that worked for @joewiz, but I still receive the same error.

So am I. Could you make succeed?

@alexjiao-chrono
Copy link

For any users who still have this error, I had to change the paths from the solution above to be:

export C_INCLUDE_PATH=/opt/homebrew/include
export CPLUS_INCLUDE_PATH=/opt/homebrew/include

System: Apple M1 running MacOS Sonoma 14.3.1

@geocomm-gbarbiani
Copy link

geocomm-gbarbiani commented Apr 10, 2024

same error on M2 chip (Macbook 14 - macOS 14.4.1 (23E224)). Tried every proposed option :(
My steps were:

  1. git clone https://github.com/kermitt2/pdfalto.git && cd pdfalto
  2. git submodule update --init --recursive
  3. export C_INCLUDE_PATH=/opt/homebrew/include; export CPLUS_INCLUDE_PATH=/opt/homebrew/include
  4. also add this line to CMakeList.txt (probably redundant): set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include" "/opt/homebrew/include")
  5. cmake .
  6. make

`
mac/pdfalto/xpdf-4.03/xpdf/GlobalParams.cc:27:12: fatal error: 'fontconfig/fontconfig.h' file not found

include <fontconfig/fontconfig.h>
^~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.

make[2]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/GlobalParams.cc.o] Error 1

make[1]: *** [xpdf-4.03/xpdf/CMakeFiles/xpdf.dir/all] Error 2

make: *** [all] Error 2
`
Also tried not installing the libs, tried not exporting those env vars, and also tried not adding CMAKE_REQUIRED_INCLUDES on CMakeList.txt, with all possible combinations returning the same error

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

No branches or pull requests

6 participants