tpisto / pdf-fill-form

Fill PDF forms and return either filled PDF or PDF created from rendered page images.
MIT License
227 stars 48 forks source link

Issue installing dependencies on Big Sur with Homebrew #104

Closed DevArenaCN closed 3 years ago

DevArenaCN commented 3 years ago

Hi, I've followed the latest setup instruction, and I'm still getting the error:

> pdf-fill-form@4.1.0 install /Users/username/Folder/task-service/node_modules/pdf-fill-form
> node-gyp rebuild

Package poppler-qt5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-qt5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-qt5' found
gyp: Call to 'pkg-config --libs  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

What I've tried: All the options mentioned here https://github.com/tpisto/pdf-fill-form/issues/87, nothing seems to be working for me.

My Env: OS: Big Sur 11.5.1 NPM version: 6.14.12 Node version: 10.24.1 Package.json: "pdf-fill-form": "^4.1.0"

I also tried updating the package to latest (5.1.0) and it didn't help either.

Thanks in advance for the help!

DevArenaCN commented 3 years ago

So, further investigation: I have poppler version 21.08.0 installed via Homebrew, which seems to have qt6 installed instead of qt5. I don't know if this is something that would require some update through the buildscript, or I would need to install a version prior.

tiholic commented 3 years ago

I've tried installing brew install poppler-qt5 and pointed the PKG_CONFIG_PATH to that dependency. But this raises QT5 errors while running make

DevArenaCN commented 3 years ago

I've managed to install poppler 21.06.1 via Homebrew, but getting a ton of what seems to me to be compiler errors:

/usr/local/opt/qt/include/QtCore/qglobal.h:675:26: error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?
         typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
         ...
 /usr/local/opt/qt/include/QtCore/qglobal.h:675:70: error: no template named 'is_arithmetic_v' in namespace 'std'; did you mean 'is_arithmetic'?
         ...
/usr/local/opt/qt/include/QtCore/qglobal.h:675:87: error: expected '>'
         typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
                                                                                      ^
/usr/local/opt/qt/include/QtCore/qglobal.h:675:37: note: to match this '<'
         typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
                                    ^
/usr/local/opt/qt/include/QtCore/qglobal.h:675:65: error: expected ',' or '>' in template-parameter-list
         typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
                                                                ^
/usr/local/opt/qt/include/QtCore/qglobal.h:676:66: error: expected unqualified-id
                                     std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
                                                                 ^
/usr/local/opt/qt/include/QtCore/qglobal.h:687:35: error: no type named 'Promoted' in namespace 'QTypeTraits::detail'
using Promoted = typename detail::Promoted<T, U>::type;
                 ~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/local/opt/qt/include/QtCore/qglobal.h:687:43: error: expected ';' after alias declaration
using Promoted = typename detail::Promoted<T, U>::type;
                                          ^
                                          ;
/usr/local/opt/qt/include/QtCore/qglobal.h:699:31: error: no template named 'Promoted' in namespace 'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qMin(const T &a, const U &b)
                 ~~~~~~~~~~~~~^
/usr/local/opt/qt/include/QtCore/qglobal.h:701:28: error: no template named 'Promoted' in namespace 'QTypeTraits'
    using P = QTypeTraits::Promoted<T, U>;
              ~~~~~~~~~~~~~^
/usr/local/opt/qt/include/QtCore/qglobal.h:702:5: error: unknown type name 'P'

And this is just some of the errors I've seen installing, not sure how to address this yet but will update this thread once I found something

DevArenaCN commented 3 years ago

OK, so the issue I think is I have multiple qt installed via Homebrew, cleaned everything up (removed all versions of poppler, and all versions of qt), then reinstall poppler @ 21.06.1, exporting the correct path:

$ export LDFLAGS=-L/usr/local/opt/qt5/lib $ export CPPFLAGS=-I/usr/local/opt/qt5/include $ export PKG_CONFIG_PATH=/usr/local/opt/qt5/lib/pkgconfig

Finally re-run npm install, that's how my issue was resolved.

Also for those who are interested in installing Poppler 21.06.1, here's what I did:

brew tap-new Homebrew/poppler-old
brew extract --version 21.06.1 poppler homebrew/poppler-old
brew install Homebrew/poppler-old/poppler@21.06.1
fabienblink commented 3 years ago

@DevArenaCN , thank you for the above, I am getting the same issue as you. Tried the below:

brew tap-new Homebrew/poppler-old
brew extract --version 21.06.1 poppler homebrew/poppler-old
brew install Homebrew/poppler-old/poppler@21.06.1

But still no luck. Can I just check which command makes sure all versions of poppler and qt are cleaned up?

Should mention here is my environment: My Env: OS: Big Sur 11.5.2 NPM version: 6.14.13 Node version: 14.17.0

The error:

> pdf-fill-form@5.1.0 install /Users/fabiendepasse/development/web/node_modules/pdf-fill-form
> node-gyp rebuild

Package poppler-qt5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-qt5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-qt5' found
gyp: Call to 'pkg-config --libs  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
DevArenaCN commented 3 years ago

@DevArenaCN , thank you for the above, I am getting the same issue as you. Tried the below:

brew tap-new Homebrew/poppler-old
brew extract --version 21.06.1 poppler homebrew/poppler-old
brew install Homebrew/poppler-old/poppler@21.06.1

But still no luck. Can I just check which command makes sure all versions of poppler and qt are cleaned up?

Should mention here is my environment: My Env: OS: Big Sur 11.5.2 NPM version: 6.14.13 Node version: 14.17.0

The error:

> pdf-fill-form@5.1.0 install /Users/fabiendepasse/development/web/node_modules/pdf-fill-form
> node-gyp rebuild

Package poppler-qt5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-qt5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-qt5' found
gyp: Call to 'pkg-config --libs  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

So what I did is run brew list, and call brew uninstall on every item that’s related to poppler and qt. So in my list I have Poppler, Poppler@21.06.1, qt, qt@5 and qt@6. So removing all those, and re-install 21.06.1 solved it for me.

tiholic commented 3 years ago

So what I did is run brew list, and call brew uninstall on every item that’s related to poppler and qt.

i.e., uninstalling all packages listed by brew list | grep -E 'poppler|qt' will do

tiholic commented 3 years ago

I fixed my problem by upgrading node from 12 -> 14.17.x

saurabh2590 commented 3 years ago

@DevArenaCN I have exactly same environment as @fabienblink . I tried the same steps:

I also have node version 14.17.x.

However, I still have the same error

> pdf-fill-form@5.1.0 install /Users/fabiendepasse/development/web/node_modules/pdf-fill-form
> node-gyp rebuild

Package poppler-qt5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-qt5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-qt5' found
gyp: Call to 'pkg-config --libs  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

Can you please guide me what I am doing wrong?

tomat commented 2 years ago

Doing this on an M1 Mac for the first time, running macOS Monterey.

I had to manually add a couple more include dirs to make it build, not sure why but may help someone else stumbling on this thread, also all homebrew paths are now /opt/homebrew instead of /usr/local etc:

export CPPFLAGS="-I/opt/homebrew/opt/qt5/include -I/opt/homebrew/Cellar/poppler@21.06.1/21.06.1/include -I/opt/homebrew/Cellar/cairo/1.16.0_5/include"

cymen commented 2 years ago

I fixed this by ensuring I only had these homebrew packages installed for qt and poppler:

% brew ls|egrep "qt|poppler"
poppler-qt5
qt@5

Then I needed to ensure my env flags were valid for both packages with:

export LDFLAGS="$LDFLAGS -L/usr/local/opt/poppler-qt5/lib"
export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/poppler-qt5/include"

export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/poppler-qt5/lib/pkgconfig"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/poppler-qt5/share/pkgconfig"

export LDFLAGS="-L/usr/local/opt/qt@5/lib $LDFLAGS"
export CPPFLAGS="-I/usr/local/opt/qt@5/include $CPPFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig:$PKG_CONFIG_PATH"

Then I was able to compile without issue while using node@14.

tiholic commented 2 years ago

On Mac M1 processor (a.k.a Apple Silicon) (a.k.a Mac ARM processor) this worked perfectly for me

brew install poppler-qt5
export LDFLAGS="-L/opt/homebrew/Cellar/qt@5/5.15.5_1/lib"
export CPPFLAGS="-I/opt/homebrew/Cellar/qt@5/5.15.5_1/include -I/opt/homebrew/Cellar/poppler-qt5/22.06.0/include -I/opt/homebrew/Cellar/cairo/1.16.0_5/include"
export PKG_CONFIG_PATH="/opt/homebrew/Cellar/qt@5/5.15.5_1/lib/pkgconfig:/opt/homebrew/Cellar/poppler-qt5/22.06.0/lib/pkgconfig"
npm i pdf-fill-form

I checked that LDFLAGS do not make any difference to installation, but leaving that instruction as-is.

Note: the version numbers are taken by checking the installed path ls /opt/homebrew/Cellar/qt@5 ls /opt/homebrew/Cellar/poppler-qt5/ ls /opt/homebrew/Cellar/cairo/

Also, this didn't work with Node.js 16.x.x, so I used node 14.20.0 to successfully install this package (based on this reference)