0

I'm relatively new to programming in C++ and while I have some experience in general coding practices, conventions etc... Recently I have come to precipice of my (limited) knowledge.

Basically I wish to write a program that will allow me to extract the annotations from a PDF file. With some research I discovered that the Poppler library would allow me to do this. So I downloaded it and began the arduous process of building it for CodeBlocks (MinGW) on Windows Vista.

For those interested, the following site provided invaluable information with regards to the building of Poppler with Cmake:

http://www.seppemagiels.com/blog/building-poppler-windows-using-mingw>

Anyway, onto my current dilemma. Having followed the out of source conventions of Cmake I have a file structure like so:

...\Work\

..............poppler-0.22.2

..............poppler-0.22.2_Build

In the "poppler-0.22.2_Build" folder there is a " libpoppler.dll.a " file which i have been led to believe is a Library folder. I have then followed the instructions as described here:

http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/

I then linked to the libpoppler.dll.a file in the "poppler-0.22.2_Build" directory and the .h files which were in the original source directory (i.e. poppler-0.22.2).

Now my question is what do i need to write in my main.cpp such that i can use the Poppler functionality. At first i just wrote:

#include "poppler.h"

However, this returned with a "No such file or directory" error. Then i tried:

#include "poppler-qt4.h"

This then executed however I was informed later in my code that "poppler" has not been declared. Then I tried:

#include "poppler-qt4.h"
#include "C:\Users\...\poppler-0.22.2\cpp\poppler-document.h"

Which then returned a "undefined reference to 'imp_ZN7poppler8document14load_from_fileERKsS2_S2_'" error...

So that's where I am right now, I have absolutely no idea how I should continue and I was hoping someone could walk me through the steps I need to take to get Poppler to work i.e. as in how do I get the library to link, if that is indeed the problem, or how do I overcome the "imp_" error. I really am at my wits end with this problem...

Thanks in advance for any help you can supply.

P.S. My main.cpp so far:

    #include <iostream>
    //#include "poppler.h"
    #include "poppler-qt4.h"
    #include "C:\Users\...\poppler-0.22.2\cpp\poppler-document.h"

    using namespace std;

    int main()
    {

    const string dir = "C:\\Users\\...\\TestPDF.pdf";

    poppler::document *doc = poppler::document::load_from_file(dir)

    return 0;
    }
precicely
  • 511
  • 6
  • 17
  • Is this about writing C++ code (and setting up a build environment using Codeblocks) or about extracting annotations of PDF files? – Enno Gröper Apr 19 '13 at 16:36
  • Hi Enno, thanks for getting back to me. Basically, I just want to be able to link to the Poppler library (which I believe I've built) and use its functionality. For example to use its "load_from_file" function. With some research I've discovered that "undefined reference to" always relates to some form of Linker error while the "_imp__" error has something to do with the conversion of C code to C++ or something of that nature however, at this point I'm in way over my head. To summarize how do I link a "dll.a" and/or how do I resolve a "_imp__" error? Thanks for any help you could provide. – precicely Apr 19 '13 at 21:43

1 Answers1

0

In Code::Blocks, right-click the name of your project and select "Build Options...". Select the option in the left-most menu that says the name of your project (should be the first option) and click "Linker Settings". Now press the "Add" button and browse to your DLL file, then press "Ok".

To allow including the header files of your library (without writing down the full path in your source code), you should tell add their location to the compiler's include path. You can do this on the "Search Directories" tab in the same window. Make sure the "Compiler" sub-tab is selected and press "Add". Browse to the the directory containing the header files and press "Ok".

Hope this helps.

Aleph
  • 1,209
  • 10
  • 19