[poppler] Poppler 0.61 build failure with MSVC

Jean Ghali jghali at libertysurf.fr
Sun Nov 12 00:35:27 UTC 2017

Hi all,

I've encountered several issues while compiling Poppler 0.61.0 for Scribus. I'm currently
using Visual Studio 2015.

The first round of issues are compiler errors caused by an undeclared strtok_r function.
The build failure has been introduced by commit 555e2ea6b6f80a6f79eeaa44a39c24dc8461e78c
which moved the declaration of strtok_r from poppler-config.h to goo/glibc.h.
Unfortunately while doing so, that commit failed to include "goo/glibc.h" in files using
the strtok_r function. As MSVC C library does not provide that function, this logically
triggers a compiler error due to the missing function declaration.

The files missing the "goo/glibc.h" include are:
- poppler/CharCodeToUnicode.cc
- poppler/GlobalParams.cc
- poppler/PDFDoc.cc
- poppler/UnicodeMap.cc

You will find in attachments a patch which fixes this issue.

Secondly, an inconsistency exists between the strtok_r declaration and its implementation:
goo/glibc.h encloses functions declaration with an extern "C" { ... }, however the
implementation of strtok_r located in glibc_strtok_r.cc, which MSVC compiles as C++, is
not enclosed with the same extern "C" { ... }. As a consequence the implementation uses
the C++ function name mangling. In the end this triggers a linker error, the linker not
being able to find a strtok_r implementation with "C" mangling. Note that the same issue
exists also in goo/glibc.cc file.

So depending on what you really want to do, I'd suggest one of these three solutions:
- removing the extern "C" {...} in goo/glibc.h
- adding the appropriate extern "C" {...} in glibc_strtok_r.cc and goo/glibc.cc
- renaming glibc_strtok_r.cc and glibc.cc by using a simple .c extension.
The third solution will force MSVC to use the C compiler by default for these two files.

Jean Ghali

-------------- next part --------------
diff -u -r a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
--- a/poppler/CharCodeToUnicode.cc	2017-11-03 11:25:02.000000000 +0100
+++ b/poppler/CharCodeToUnicode.cc	2017-11-11 01:14:46.821015300 +0100
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <string.h>
+#include "goo/glibc.h"
 #include "goo/gmem.h"
 #include "goo/gfile.h"
 #include "goo/GooLikely.h"
diff -u -r a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
--- a/poppler/GlobalParams.cc	2017-11-03 11:25:02.000000000 +0100
+++ b/poppler/GlobalParams.cc	2017-11-11 01:15:30.793525300 +0100
@@ -60,6 +60,7 @@
 #  include <shlobj.h>
 #  include <mbstring.h>
+#include "goo/glibc.h"
 #include "goo/gmem.h"
 #include "goo/GooString.h"
 #include "goo/GooList.h"
diff -u -r a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
--- a/poppler/PDFDoc.cc	2017-11-03 11:25:02.000000000 +0100
+++ b/poppler/PDFDoc.cc	2017-11-11 01:15:56.077971500 +0100
@@ -57,6 +57,7 @@
 #include <string.h>
 #include <time.h>
 #include <sys/stat.h>
+#include "goo/glibc.h"
 #include "goo/gstrtod.h"
 #include "goo/GooString.h"
 #include "goo/gfile.h"
diff -u -r a/poppler/UnicodeMap.cc b/poppler/UnicodeMap.cc
--- a/poppler/UnicodeMap.cc	2017-11-03 11:25:02.000000000 +0100
+++ b/poppler/UnicodeMap.cc	2017-11-11 01:16:25.738668000 +0100
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <string.h>
+#include "goo/glibc.h"
 #include "goo/gmem.h"
 #include "goo/gfile.h"
 #include "goo/GooString.h"

More information about the poppler mailing list