vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
584 stars 83 forks source link

Compiling failed using most recent MSYS/MingW64 #282

Open ShuguangSun opened 1 month ago

ShuguangSun commented 1 month ago

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:

Your pdf-tools install Please complete the following information:

45mg commented 1 month ago

Same issue.

vedang commented 1 month ago

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.

svraka commented 1 month ago

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 commented 4 weeks ago

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 commented 3 weeks ago
./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 commented 16 hours ago

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?