I am using macOS Mojave and was unable to build this package. This pull request fixes the two issues - getCString error and compiler flag issue in Mojave.
pdfparser/poppler.cpp:8811:41: error: no member named 'getCString' in 'GooString'
__pyx_t_12 = __pyx_v_font_name->getCString();
~~~~~~~~~~~~~~~~~ ^
pdfparser/poppler.cpp:8910:29: error: no member named 'getCString' in 'GooString'
__pyx_t_12 = __pyx_v_s->getCString();
~~~~~~~~~ ^
Solution
If I check the header file, then I see that for poppler 0.74.0 there is no getCString, and instead c_str() should be used. The proposed code changes should be backwards compatible with older Poppler versions - in the code I used conditional compilation with variable USE_CSTRING in Cython.
g++ -bundle -undefined dynamic_lookup -L/Users/myname/miniconda3/envs/myenv/lib -arch x86_64 -L/Users/myname/miniconda3/envs/myenv/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.7/pdfparser/poppler.o -L/usr/local/Cellar/poppler/0.74.0/lib -L/usr/local/Cellar/poppler/0.74.0/lib -lpoppler -lpoppler-cpp -o build/lib.macosx-10.7-x86_64-3.7/pdfparser/poppler.cpython-37m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
Solution
Add extra_link_args, then g++ command will contain -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 flags at the end:
I am using macOS Mojave and was unable to build this package. This pull request fixes the two issues -
getCString
error and compiler flag issue in Mojave.Reproduction
getCString
error (goo/GooString
)First error is about
getCString
, see:Solution
If I check the header file, then I see that for poppler 0.74.0 there is no
getCString
, and insteadc_str()
should be used. The proposed code changes should be backwards compatible with older Poppler versions - in the code I used conditional compilation with variableUSE_CSTRING
in Cython.File:
/usr/local/Cellar/poppler/0.74.0/include/poppler/goo/GooString.h
This change was in
Poppler 0.72.0
, see https://gitlab.freedesktop.org/poppler/poppler/commit/817b0f12453985c416a0388cdd4a09697d092b7fmacOS Mojave issue with
libc++
CFLAGWhen poppler config contains only
extra_compile_args
, they don't get propagated to theg++
:I get the error:
Solution
Add
extra_link_args
, theng++
command will contain-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7
flags at the end:There is also a workaround by just specifying the compiler flag in the command line: