[poppler] Linking Poppler to Code::Blocks

Christopher Icely christophericely at gmail.com
Sat Apr 20 11:20:42 PDT 2013


Good Day All,

Firstly, I do apologize if this is the incorrect forum in which to ask my
questions however, I'm really at my wit's end with this problem and I was
hoping one of you could perhaps help me.

Basically I wish to write code that will allow me to extract annotations
from PDFs. However, I'm yet to write any code as I've spent an inordinate
amount of time in just getting Poppler built. These are the steps I've
followed so far:

{System specs: Windows 7, MinGW, CodeBlocks}

1) I have a folder structure like so:
    C:\Users\Chris\Documents\Poppler\build\
    ------------------------->poppler-0.22.2
    ------------------------->poppler-0.22.2_Build

The file "poppler-0.22.2" is the unzipped source files while the
"poppler-0.22.2_Build" file was made by the Cmake GUI with Cairo, JPEG, QT4
and TIFF included. Furthermore, Cmake was instructed to generate a
"CodeBlocks - MinGW Makefiles".

2) After the CodeBlocks project was generated by Cmake, the project was
built in CodeBlocks and I was left with the following:

    C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\
    -------------------------->CMakeFiles
    -------------------------->cpp
    -------------------------->poppler
    -------------------------->qt4
    -------------------------->test
    -------------------------->utils
    -------------------------->cmake_install.cmake
    -------------------------->CMakeCache
    -------------------------->config.h
    -------------------------->CTestfile.cmake
    -------------------------->libpoppler.dll
    -------------------------->libpoppler.dll.a
    -------------------------->Makefile
    -------------------------->poppler.cbp
    -------------------------->poppler.layout

3) Now i need to link the poppler library to my project. Therefore in
CodeBlocks I did the following:

a)Settings->Compiler->Linker settings: Link libraries
    and I set the path to:
C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\libpoppler.dll.a

b)Then in  Settings->Compiler->Search directories->Linker
    I set the path to:
C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\

c)Then I set up the linking for my project:
    Project->Build Options->Linker settings
    and set the path to
C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\libpoppler.dll.a

d)And finally:
    Project->Build Options->Search directories->Linker
    and add the path:
C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\

4) I have now written the following code in my main.cpp just to see if
everything works:

1 : #include <iostream>
2 : #include
"C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2\cpp\poppler-global.h"
3 : #include
"C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2\cpp\poppler-document.h"
4 :
5 : using namespace std;
6 :
7 : int main()
8 : {
9 :
10:
11:   const string dir =
"C:\\Users\\Chris\\Documents\\WorkForDad\\2013\\Pdf Automation\\Anotation
Extraction\\Remuneration Report.pdf";
12:
13:    poppler::document *doc = poppler::document::load_from_file(dir);
14:
15:    return 0;
16: }

However, I get the following error in my"Build messages" when I build the
code:


C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp||In function 'int main()':|
C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp|13|warning: unused variable 'doc'
[-Wunused-variable]|
obj\Debug\main.o||In function `main':|
C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp|13|undefined reference to
`_imp___ZN7poppler8document14load_from_fileERKSsS2_S2_'|
||=== Build finished: 1 errors, 1 warnings (0 minutes, 1 seconds) ===|


###


And in the "Build log" I get the following:


-------------- Clean: Debug in Clean (compiler: GNU GCC
Compiler)---------------

Cleaned "Clean - Debug"

-------------- Build: Debug in Clean (compiler: GNU GCC
Compiler)---------------

mingw32-g++.exe -Wall -fexceptions  -g  -g    -c
"C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp" -o obj\Debug\main.o
C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp: In function 'int main()':
C:\Users\Chris\Documents\WorkForDad\2013\Pdf
Automation\Test\Clean\main.cpp:13:24: warning: unused variable 'doc'
[-Wunused-variable]
mingw32-g++.exe -L..\..\..\..\..\Poppler\build\poppler-0.22.2_Build
-LC:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build  -o
bin\Debug\Clean.exe obj\Debug\main.o
..\..\..\..\..\Poppler\build\poppler-0.22.2_Build\libpoppler.dll.a
C:\Users\Chris\Documents\Poppler\build\poppler-0.22.2_Build\libpoppler.dll.a

obj\Debug\main.o: In function `main':
C:/Users/Chris/Documents/WorkForDad/2013/Pdf
Automation/Test/Clean/main.cpp:13: *undefined reference to
`_imp___ZN7poppler8document14load_from_fileERKSsS2_S2_'*
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 1 warnings (0 minutes, 1 seconds)



###


So as you can see, the problem would seem to be a linking error of some
sort due to the presence of : "undefined reference to
`_imp___ZN7poppler8document14load_from_fileERKSsS2_S2_'"

Also, I have no idea what the "_imp__" + (random characters) means. From
some research I've discovered that this "_imp__" problem has something to
do with C to C++ code conversion however I have no idea if this is the case
now or how I would go out about fixing this problem.

So there it all is, I hope someone can help me and I really appreciate all
of you who took the time to read the above and for any assistance you can
provide me.

Kind Regards
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130420/5c974383/attachment.html>


More information about the poppler mailing list