[poppler] poppler static compilation and linking with VC++ 2008
Marco Antonio Pincheira
adikkto at gmail.com
Mon Jan 31 09:41:50 PST 2011
I have been trying from a few days ago to generate a static version of
the poppler library, specifically of the qt version (poppler-qt4), for
using in Windows.
I was searching on the Internet, I found KDE Windows Initiative, where I
could download the binaries and source codes from poppler and most of
its dependencies, but cairo. The problem was that this binaries files
were dynamic and, from the files with .lib extension (poppler.lib,
poppler-cpp.lib, poppler-qt4.lib), only poppler.lib was a static library.
Due to this, and using the cMake files content in the download of the
source code of poppler I tried to generate static versions from all the
dependencies of poppler, which was an easy thing to do except with
cairo, that was a little big harder to do using the msvc2008 compiler.
When I had the static version I tried to generate a basic application
made in qt4, which has the poppler-qt4.lib library.
The mencionated application is the following:
MainWindow::MainWindow(QWidget *parent) :
QString filename = "C:\\file.pdf";
Poppler::Document *doc = Poppler::Document::load(filename);
The file with extension .pro is the following:
QT += core gui
TARGET = poppler-static
TEMPLATE = app
SOURCES += main.cpp\
HEADERS += mainwindow.h
FORMS += mainwindow.ui
and the error message I got with the link, is the following:
error LNK2019: unresolved external symbol "__declspec(dllimport) public:
static class Poppler::Document * __cdecl Poppler::Document::load(class
QString const &,class QByteArray const &,class QByteArray const &)"
(__imp_?load at Document@Poppler@@SAPAV12 at ABVQString@@ABVQByteArray@@1 at Z)
referenced in function "public: __thiscall MainWindow::MainWindow(class
QWidget *)" (??0MainWindow@@QAE at PAVQWidget@@@Z)
The funny thing is that using the dumpbin tool from Visual Studio, when
I execute the command: "dumpbin /headers poppler-qt4.lib", all the
functions that the library contains appear and in the output generated I
SECTION HEADER #25E
0 physical address
0 virtual address
155 size of raw data
FA88 file pointer to raw data (0000FA88 to 0000FBDC)
FBDD file pointer to relocation table
0 file pointer to line numbers
D number of relocations
0 number of line numbers
COMDAT; sym= "public: static class Poppler::Document * __cdecl
Poppler::Document::load(class QString const &,class QByteArray const
&,class QByteArray const &)"
(?load at Document@Poppler@@SAPAV12 at ABVQString@@ABVQByteArray@@1 at Z)
16 byte align
This makes a direct reference to the method that is called in the
previous code shown.
Another important detail is that when I eliminate the inclusion of
poppler-qt4.lib in the proyect's properties, I'm getting the same error,
as if it's not being used and if I use the dynamic version the program
gets compiled without any problem but the resultant executable asks for
the respecive dll (logically).
I don't know if this is due to poppler more than to qt, but I'm going to
post it in both to see if somebody can help me with this error, because
I just can't understand the reason why the link fails if the library
contains the right solicited function.
As an additional information, my operative system is Windows 7 64-bits
and I'm using Visual Studio 2008. The application is compiled in release
for 32 bits using the static build of qt 4.7.1 built with the msvc2008.
Thank you very much in advance to everybody who analize this.
More information about the poppler