paulovap / qtpdfium

Pdf Redening on Qt
BSD 3-Clause "New" or "Revised" License
220 stars 91 forks source link

Build issues on Windows and Linux #15

Open iondevsrl opened 7 years ago

iondevsrl commented 7 years ago

Hi,

First of all thanks for your work on QtPdfium. I tried it on Linux and Windows and I have encountered the following issues:

  1. On Linux Ubuntu 16.04 64-bit with Qt version 5.5.1 and gcc version 5.4.0 the library itself can be built out of the box but when trying to use it there's a compile error message:

/src/pdfium/qpdfium.h:52:36: error: ‘>>’ should be ‘> >’ within a nested template argument list QVector<QWeakPointer> m_pages;

In order to fix it, you need to change the incriminated line to: QVector<QWeakPointer > m_pages;

  1. On Windows 10 64-bit with Qt 5.6.1 and MinGW compiler (gcc version 5.4.0, built by MSYS2 project) the compilation fails with the error message bellow.

Could you, please, add support for the MinGW compiler?

Thanks in advance for your help and best regards, Ion

make[3]: Entering directory '/c/qtiplot/3rdparty/qtpdfium/src/pdfium' g++ -c -pipe -fno-keep-inline-dllexport -march=nocona -mtune=core2 -Wa,-mbig-obj -O2 -std=c++1z -Wall -Wextra -fno-exceptions -frtti -DUNICODE -DQT -DOPJ_STATIC -DPNG_PREFIX -DPNG_USE_READ_MACROS -DQT_NO_VERSION_TAGGING -DQT_BUILD_PDFIUM_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DFT2_BUILD_LIBRARY -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -IC:/msys64/mingw64/include/dbus-1.0 -IC:/msys64/mingw64/lib/dbus-1.0/include -IC:/msys64/mingw64/include/libxml2 -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/mariadb -I../../include -I../../include/QtPdfium -IC:/qtiplot/3rdparty/qtpdfium/include/QtPdfium/5.5.0 -IC:/qtiplot/3rdparty/qtpdfium/include/QtPdfium/5.5.0/QtPdfium -Itmp -I../3rdparty/pdfium -I../3rdparty/pdfium/third_party/freetype/include -I../3rdparty/pdfium/third_party/freetype/include/freetype -IC:/msys64/mingw64/include/QtCore/5.6.1 -IC:/msys64/mingw64/include/QtCore/5.6.1/QtCore -IC:/msys64/mingw64/include/QtGui -IC:/msys64/mingw64/include/QtCore -I.moc/release -IC:/msys64/mingw64/share/qt5/mkspecs/win32-g++ -o .obj/release/fpdfview.o ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp In file included from ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_indirect_object_holder.h:15:0, from ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_array.h:16, from ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:15: ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_object.h:117:34: warning: unused parameter 'src' [-Wunused-parameter] CPDF_Object(const CPDF_Object& src) {} ^ ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_object.h:117:34: warning: unused parameter 'src' [-Wunused-parameter] ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp: In function 'FPDF_BOOL FPDF_SetPrintPostscriptLevel(int)': ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:447:3: error: 'g_pdfium_print_postscript_level' was not declared in this scope g_pdfium_print_postscript_level = postscript_level; ^ ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp: In function 'void FPDF_RenderPage(HDC, FPDF_PAGE, int, int, int, int, int, int)': ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:681:46: error: 'CFX_WindowsDevice' was not declared in this scope pContext->m_pDevice = pdfium::MakeUnique(dc); ^ ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:681:67: error: no matching function for call to 'MakeUnique(HDC__*&)' pContext->m_pDevice = pdfium::MakeUnique(dc);

pinaraf commented 7 years ago

I just reported a compilation issue when using MSVC++ under windows. Current master does not compile under windows so far. Could you try an older revision, 4201c6a ? This could help pinpoint the issue…

iondevsrl commented 7 years ago

I've just tried to compile using the revision you indicated and qmake complains about missing files. Do you have other suggestion?

pinaraf commented 7 years ago

Did you also update the submodule ? It should build fine, or at least not complain about missing files…

iondevsrl commented 7 years ago

You're right, after updating the submodule the error message about missing files disappears, but I get a compile error, first error line shown bellow:

./3rdparty/pdfium/core/src/fxcrt/../../include/fxcrt/fx_system.h:126:25: error: expected unqualified-id before 'void'

define FXSYS_snprintf (void) snprintf

After I edit the header file fx_system.h in order to fix this error I get a 2nd error message, which is the same that I get when I try to compile QtPdf module (https://github.com/qt-labs/qtpdf):

../3rdparty/pdfium/core/src/fxcrt/fx_basic_util.cpp:172:21: error: '_Printf_formatstring' has not been declared _Printf_formatstring const char* fmt

paulovap commented 7 years ago

Hey! @iondevsrl @pinaraf I don't have a Windows nor Linux machine at the moment, so I can only test on Mac/iOS/Android. I will try to setup an old notebook to fix this. But PRs are also greatly appreciated!

pinaraf commented 7 years ago

I don't have any issue building on Linux with G++ 6.3.0 / Qt 5.7. But I will have to target Windows users and I must use MSVC++, so I can help cover these two targets.

iondevsrl commented 7 years ago

As explained in my initial post, the fix for gcc 5.4 on Linux is very simple. The error message is:

/src/pdfium/qpdfium.h:52:36: error: ‘>>’ should be ‘> >’ within a nested template argument list

Therefore all you have to do is add a space character.

On Windows I can only use MinGW and I can also help with builds and testing for this compiler.

By the way, would you be interested in having QtPdfium work with Qt4? Just with a few extra #if QT_VERSION < 0x050000 lines I was able to get it work on Linux.

pinaraf commented 7 years ago

'>>' vs '> >' is a classical C++ gotcha related to C++11/14. I think the code is missing a CONFIG += c++11 in the corresponding qmake files.

coooooooorey commented 7 years ago

@iondevsrl did you succeed on building on Windows?

I tried this project two years ago on Windows and OS X, and submitted the first issue. It's all good then. Now it works fine on OS X, but it's really hard to build on Windows. I'm using msvc2015 Qt 5.9.

paulovap commented 7 years ago

Hi @coooooooorey, unfortunately, I don't have a Windows machine anymore, so it is hard to me to test on Windows. Can you send me the error message?

coooooooorey commented 7 years ago

I think it's the Marco issue.

It's looking for some Linux headers on windows

coooooooorey commented 7 years ago

It seems like some functions on windows didn't implement

weis commented 7 years ago

Hi coooooooorey, with Qt 5.6.2, MSVC2015, 32bit I have done following steps:

  1. git bash console: git clone --recursive https://github.com/paulovap/qtpdfium
  2. Qt Creator: 2.1 Open qtpdfium.pro, choose above kit, 2.2 Run qmake 2.3 Build project

Produced hundreds of warning, but no errors. All libs are placed in the output path.

aquiles2k commented 6 years ago

I managed to build it with some changes on win msys2 mingw with qt 5.9.1. @paulovap is there any chance you'll ever update the pdfium code? It seems its from 2015.

paulovap commented 6 years ago

@aquiles2k hey there. I don't have the time to update the project since I am not using it anymore, but I would welcome patches to keep it up to date. I also don't have a Windows machine, so its hard for me to make sure it is working on every platform. I would love to review your changes!

Vadixem commented 6 years ago

qtpdf_compile_bug_2 Trying to compile on windows 10 x64 using qtcreator 4.1 and mscv2015_x32 I get 10 issues about missing file, lurking through filetree I found that file. \qtpdf\src\3rdparty\pdfium\third_party\freetype\src\base\ftglyph.c:31: error: C1083: Cannot open include file: 'ft2build.h': No such file or directory Please see picture attached. I don't know what to do qtpdf_compile_bug

JeromeDesfieux commented 5 years ago

I have same issue as you Vadixem. Did you find a solution?