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

Compiling failed using most recent MSYS/MingW64 #282

Open
ShuguangSun opened this issue Jun 3, 2024 · 13 comments
Open

Compiling failed using most recent MSYS/MingW64 #282

ShuguangSun opened this issue Jun 3, 2024 · 13 comments
Labels
help wanted Extra attention is needed MSWindows Issues related to running pdf-tools on Windows

Comments

@ShuguangSun
Copy link
Contributor

Describe the bug
Compiling failed using most recent MSYS/MingW64 in Windows.

Steps to Reproduce the behaviour
Steps to reproduce the behaviour:

  1. update to the most recent MSYS/MingW64
  2. Emacs 30.0.50 (most recent git version)
  3. Compile pdf-tools
  4. See error below
Is case-sensitive searching enabled ?     yes
Is modifying text annotations enabled ?   yes
Is modifying markup annotations enabled ? yes

test -z "epdfinfo.exe" || rm -f epdfinfo.exe
test -z "libsynctex.a" || rm -f libsynctex.a
rm -f *.o
epdfinfo.c: In function 'annotation_markup_append_text_region':
epdfinfo.c:1576:5: warning: 'poppler_page_get_selection_region' is deprecated: Use poppler_page_get_selected_region instead [-Wdeprecated-declarations]
 1576 |     poppler_page_get_selection_region (page, 1.0, selection_style, region);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/poppler/glib/poppler.h:251,
                 from epdfinfo.c:28:
C:/msys64/mingw64/include/poppler/glib/poppler-page.h:75:8: note: declared here
   75 | GList *poppler_page_get_selection_region(PopplerPage *page, gdouble scale, PopplerSelectionStyle style, PopplerRectangle *selection) G_GNUC_DEPRECATED_FOR(poppler_page_get_selected_region);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
synctex_parser.c: In function '_synctex_updater_print_gz':
synctex_parser.c:8448:13: error: implicit declaration of function 'vasprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
 8448 |         if (vasprintf(&buffer, format, va) < 0) {
      |             ^~~~~~~~~
      |             vsprintf
make[1]: *** [Makefile:484: libsynctex_a-synctex_parser.o] Error 1
make: *** [Makefile:346: all] Error 2
===========================
     Build failed.  ;o(
===========================
Note: maybe try the '-d' option.

Desktop
Please complete the following information:

  • OS: Window 10
  • Emacs Version: 30.0.50 (git version)
  • Poppler Version: 24.05.0-1

Your pdf-tools install
Please complete the following information:

  • pdf-tools Version: pdf-tools-20240429.407
@45mg
Copy link

45mg commented Jun 5, 2024

Same issue.

  • pdf-tools a1048bc (Doom Emacs)
  • Msys2 2024-05-07 (latest)
  • Emacs 29.1
  • Windows 11

@vedang
Copy link
Owner

vedang commented Jun 5, 2024

The vasprintf implicit declaration means that it isn't finding the header files. Can you try the following in the latest pdf-tools directory?

./autogen.sh
CFLAGS='-g -O2 -D_GNU_SOURCE' ./configure
make

If this compiles properly, then I'll check how to incorporate the fix into the master branch.

I do not use Windows and have no way to test this myself.

@vedang vedang added help wanted Extra attention is needed MSWindows Issues related to running pdf-tools on Windows labels Jun 5, 2024
@svraka
Copy link
Contributor

svraka commented Jun 6, 2024

In the prebuilt MSY2 package we have been using CFLAGS+=' -D_GNU_SOURCE for a while, and successfully reran the package build with the latest pdf-tools commit. The autobuild script though doesnt' set _GNU_SOURCE.

@ShuguangSun
Copy link
Contributor Author

The vasprintf implicit declaration means that it isn't finding the header files. Can you try the following in the latest pdf-tools directory?

./autogen.sh
CFLAGS='-g -O2 -D_GNU_SOURCE' ./configure
make

This works.

@45mg
Copy link

45mg commented Jun 11, 2024

./autogen.sh
CFLAGS='-g -O2 -D_GNU_SOURCE' ./configure
make

Hi, sorry for the delay. I can confirm that the compilation succeeds with the above instructions.

@Beakcraft
Copy link

Beakcraft commented Jul 6, 2024

I m sorry I posted the exact same issue as a new issue (sry noob here) Can you give exact instuctions on how and where to implement:

./autogen.sh
CFLAGS='-g -O2 -D_GNU_SOURCE' ./configure
make

I had originally edited the .c file, but came to realize the this might have broken my synctex functionality.
Please help I would love to write my paper in auctex. How and where to I put/execute that code snipped.

Do i need to run that in Msys2 or in Emacs or cmd or mingw64?

@Beakcraft
Copy link

alright, I now let the compiler run and fail. then it had created the configure file. in the file i searched for CFLAGS="-g -02" which is on line 4103 added the "-D_GNU_SOURCE" resulting in= CFLAGS="-g -O2 -D_GNU_SOURCE", and now
make[1]: Nothing to be done for 'install-data-am'.
make[1]: Leaving directory

===========================
Build succeeded. :O)

but unfortunately when compiling latexmk with C-c C-a to an already open window(.pdf in PDFviewer) it gives the error:
epdfinfo: Unable to create synctex scanner, did you run latex with `--synctex=1' ?
Help :((( The result is the same when i edit the config.ac file, i get a successful build but it still does not work properly.

@vedang
Copy link
Owner

vedang commented Jul 8, 2024

@Beakcraft : could you try and follow the instructions here https://pdftools.wiki/d14e01ff and see if they help you?

And if you don't want to compile from source, you can also try installing from the msys2 package manager via https://packages.msys2.org/package/mingw-w64-x86_64-emacs-pdf-tools-server?repo=mingw64

@Beakcraft
Copy link

@vedang Well no difference synctex still does not work as it should. Either the Error tells a real issue or in case of circumventing the error my init.el file is just not sufficient. Anyways I ll make it work. Recomiling and updating with latexmk works at least.

(setq inhibit-startup-screen t)     ; Disable normal starting screen
(scroll-bar-mode -1)                ; Disable visual scrollbar
(tool-bar-mode -1)		    ; Disable the toolbar
(tooltip-mode -1)                   ; Disable tooltips
(set-fringe-mode 20)                ; Gives some space
(menu-bar-mode -1)                  ; Disable menu bar
(setq split-width-threshold 1)    ;vertical(window left-right) split set as default
;(load-theme 'tango-dark t)       ; Dark Theme
(push '(fullscreen . maximized) default-frame-alist) ;fullscreen on default

(set-default-coding-systems 'utf-8) ; make utf-8 encoding beacuse Umlaute (öäü) would not decode otherwise
(set-language-environment 'utf-8)
(set-selection-coding-system 'utf-8)

;; Initialize package sources
(require 'package)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("org" . "https://orgmode.org/elpa/")
                         ("elpa" . "https://elpa.gnu.org/packages/")))


(package-initialize)
(unless package-archive-contents
 (package-refresh-contents))

;; Initialize use-package on non-Linux platforms
(unless (package-installed-p 'use-package)
   (package-install 'use-package)) 

(require 'use-package)
(setq use-package-always-ensure t)


(require 'yasnippet)

(use-package tex
  :ensure auctex
  :mode ("\\.tex\\$" . latex-mode)
  :custom
  (TeX-source-correlate-mode t)
  (TeX-source-correlate-method 'synctax)
  (TeX-auto-save t)
  (TeX-parse-self t)
  (TeX-electric-math (cons "$" "$"))
  (LaTeX-electric-left-right-brace t)
  (reftex-plug-into-AUCTeX t)
  (TeX-view-program-selection '((output-pdf "PDF Tools")))
  (TeX-source-correlate-start-server t)
  (TeX-master nil)
  :config
  (defun save-and-compile ()
    (interactive)
    (let (TeX-save-query) (TeX-save-document (TeX-master-file)))
    (TeX-command-run-all nil))
  (bind-key "<f5>" 'save-and-compile)
  (progn
    (pdf-loader-install)
    ;; Update PDF buffers after successful LaTeX runs
    (add-hook 'TeX-after-compilation-finished-functions
	      #'TeX-revert-document-buffer)
    (yas-reload-all)
    (add-hook 'LaTeX-mode-hook
	      (lambda ()
		(reftex-mode t)   ;Activate nice interface betweene Reftex and Auctex i guess
		(flyspell-mode t)
		(company-mode t)
		(yas-minor-mode t)
		(LaTeX-math-mode t)
		(tex-fold-mode 1)
		;; Set Latexmk to be the default compiler
		(setq TeX-command-default "LatexMk")))))

(use-package reftex
  :defer t
  :custom
  (reftex-cite-prompt-optional-args t)) ; Prompt for empty optional arguments in cite

(use-package pdf-tools
  :mode ("\\.pdf\\'" . pdf-tools-modes)
  :custom
  (pdf-view-display-size 'fit-width)
  (pdf-annot-activate-created-annotations t)
  :config
  (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
  (define-key pdf-view-mode-map (kbd "C-r") 'isearch-backward)
  )
(use-package auctex-latexmk
  :after tex
  :custom
  (auctex-latexmk-inherit-TeX-PDF-mode t)
  :config
  (auctex-latexmk-setup))


(use-package company-auctex
  :pin melpa
  :after tex
  :init
  (company-auctex-init))

@Beakcraft
Copy link

Beakcraft commented Jul 10, 2024

uuum i think i found the problem, synctex has issues with a synced folder outside of the (at least) C directory, i have a google synced folder in which i perform the compilation.
This issue seems to persist in many many threads unsolved dating back to at least 2017 (doomemacs/doomemacs#5249) for example. i think there are even instances far earlier. Maybe you can help debug this: pdf-info-log

00:07:17 synctex-backward-search:g\:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/main.pdf:3:0.3970037453183521:0.45717592592592593
00:07:17 ERR
Unable to create synctex scanner, did you run latex with `--synctex=1' ?
.
00:08:58 synctex-forward-search:g\:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/main.pdf:g\:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./main.tex:39:0
00:08:58 ERR
Unable to create synctex scanner, did you run latex with `--synctex=1' ?
.

Weather this error and the previous one are connected no clue soz. But that rn is definitly some kind of pathing error, which can likly be easily resolved.
main.synctex
SyncTeX Version:1
Input:1:g:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./main.tex
Input:2:c:/texlive/2024/texmf-dist/tex/latex/base/report.cls
Input:3:c:/texlive/2024/texmf-dist/tex/latex/base/size12.clo
Input:4:c:/texlive/2024/texmf-dist/tex/latex/graphics/graphicx.sty
Input:5:c:/texlive/2024/texmf-dist/tex/latex/graphics/keyval.sty
Input:6:c:/texlive/2024/texmf-dist/tex/latex/graphics/graphics.sty
Input:7:c:/texlive/2024/texmf-dist/tex/latex/graphics/trig.sty
Input:8:c:/texlive/2024/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
Input:9:c:/texlive/2024/texmf-dist/tex/latex/graphics-def/pdftex.def
Input:10:c:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
Input:11:g:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./main.aux
Input:12:c:/texlive/2024/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
Input:13:c:/texlive/2024/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
Input:14:c:/texlive/2024/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
Output:pdf
Input:15:g:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./main.toc
Input:16:g:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./chapters/Rechtsstaatlichkeit.tex
---same as previous---2x
Input:19:g:/My Drive/br Uni/Bacholerarbeit/Öffentliches Recht/Fuchs/EMACS file/./main.aux

@jaccarmac
Copy link

jaccarmac commented Jul 27, 2024

SyncTeX has included a fix for this since jlaurens/synctex#39 (I discovered it via jlaurens/synctex#80). Inserting the #define line into my source tree is necessary now using Guix to get pdf-tools to build. I have not yet tried the -D version of the fix.

@jaccarmac
Copy link

jaccarmac commented Jul 29, 2024

@vedang

If this compiles properly, then I'll check how to incorporate the fix into the master branch.

I'm not sure how much of a plan you have about the correct way to do this, but I did some poking as an autoconf novice.

Inserting CFLAGS="-D_GNU_SOURCE $CFLAGS" into configure.ac before the conditional CFLAGS for MinGW works, but felt a little clumsy. I looked into AC_GNU_SOURCE, which appears to be deprecated in favor of AC_USE_SYSTEM_EXTENSIONS. That can work, but synctex_parser.c needs to have the config.h include added to it.

I can provide reproduction instructions for the issue on Linux via Guix; haven't discovered when exactly the breakage happened. Best fix depends on how the subsets of the project are supposed to nest, so I won't presume to have a PR ready.

jaccarmac added a commit to jaccarmac/dot-emacs-dot-d that referenced this issue Jul 30, 2024
FossilOrigin-Name: 2609b52757f2f067ca842ce43f932e9487cf145eb12042cede23fe620f664126
@michaelmhoffman
Copy link

michaelmhoffman commented Aug 2, 2024

This workaround successfully installs epdfinfo for me without editing any files:

(with-environment-variables
    (("CFLAGS"
      (mapconcat #'identity `("-D_GNU_SOURCE" ,(getenv "CFLAGS")) " ")))
  (pdf-tools-install))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed MSWindows Issues related to running pdf-tools on Windows
Projects
None yet
Development

No branches or pull requests

7 participants