dawbarton / pdf2svg

A simple PDF to SVG converter using the Poppler and Cairo libraries
GNU General Public License v2.0
616 stars 81 forks source link

Any advice on how to build a standalone binary for linux? #5

Open alnutile opened 9 years ago

alnutile commented 9 years ago

The boxes I need this to run on I can not download or install anything on but I can include in my git repo a binary as I already to with pdftk.

But this tool would be a lot better option since it does both steps for me in one eg make pages and images.

Thanks for you work!


it is an ubuntu box I need to make this for btw. I tried this http://jurjenbokma.com/ApprenticesNotes/getting_statlinked_binaries_on_debian.html but it did not work.

mardukbp commented 8 years ago

If using your (pressumably remote) git repo is an option, then I suggest you install junest. When you are done installing and adding junest to your $PATH, do the following:

junest -f
pacman -Syy
pacman -S pdf2svg

Exit junest (Ctrl-D) and setup an alias in your .bashrc:

alias pdf2svg='junest -- pdf2svg'

Close the Terminal and open a new one.

Enjoy!

mardukbp commented 8 years ago

Here's a more portable procedure:

  1. On a Linux (possibly virtual) machine where pdf2svg is installed download the CARE binary.
  2. Make it executable chmod +x care-x86_64
  3. Wrap pdf2svg in a self-contained environment: ./care-x86_64 pdf2svg
  4. On the machine where you want to use pdf2svg extract the archive: ./care-XXXX.bin
  5. Tell CARE about the directory where your PDFs are stored:
    1. nano care-XXXX/re-execute.sh
    2. Scroll down until you find lines starting with -b
    3. Add the following line to the family: -b "/home/USER/path/to/your/pdfs" \
    4. Find the line nearby that begins with -w and update your $HOME accordingly.
    5. Save (Ctrl + O) and exit (Ctrl + X)
  6. Run ./care-XXXX/re-execute.sh pdf2svg /home/USER/path/to/your/pdfs/file.pdf /home/USER/path/to/your/pdfs/file.svg

Enjoy!

rgpublic commented 5 years ago

Quite an old issue, but with the great help of the poppler folks, I finally I managed to build a true completely static pdf2svg binary. Perhaps this is also useful for others, so I'm posting it here. I used an Ubuntu Cosmic docker container to build it. Here is the relevant excerpt of the docker file:

https://gist.github.com/rgpublic/1a721599332402f55625afc3886b967a

Even if you don't want to use Docker and/or a Docker file, the necessary steps are pretty easy to understand as you can see.

NB: Working inside a docker container is only recommended in order to not spoil your system with all the unnecessary installs and packages. After you've build the static binary, you can take it anywhere and run it. Docker is NOT required later to use the static binary, of course.

The resulting binary is about 17 MB.

DanieW commented 4 years ago

Today (2020-09-23) I managed to compile this on CentOS 8. I needed to make some adaptions as follows:

Comment out line 90 in the source code by inserting "//" at the beginning of the line.: { pdf2svg.c:90:2: warning: ‘g_type_init’ is deprecated [-Wdeprecated-declarations] }

In order to have the development libraries available for compiling: dnf install poppler-devel dnf install poppler-glib-devel

Changed configure's line 2072 to "if true ; then " to bypass the deprecated test. { if eval "$MISSING --is-lightweight"; then -- is outdated}

I also could not find the code in pdf2svg-0.2.3-12.fc33.src.rpm

dawbarton commented 4 years ago

Today (2020-09-23) I managed to compile this on CentOS 8. I needed to make some adaptions as follows:

@DanieW: would you be able to submit a PR with these changes in? I'm sure others would appreciate them,

DanieW commented 4 years ago

Sorry, I was mistaken. It seems I have to do: cat pdf2svg-0.2.3-12.fc33.src.rpm | rpm2cpio - | cpio -tv to extract the source, whereas I tried rpm -ivh --prefix=/opt pdf2svg-0.2.3-12.fc33.src.rpm But still I propose the changes above.