Undefined reference to PoDoFo::...

Jun 27, 2012 at 7:59pm
I'm trying to do a program that will read a pdf we get from work with our schedule, and give a file in the icalendar or csv format (or some other format if my friends asks for it) so we can sync it with our calendars (eg google calendar). I've looked for libraries that parse pdf's and the best one so far seems to be PoDoFo (http://podofo.sourceforge.net/index.html). So since I'm on Ubuntu I installed the libpodofo-dev package from the default repositories.

I have podofo/base/PdfParser.h and podofo/base/PdfVecObjects.h included, but it seems like my compiler can't find it. I get these error messages:
1
2
3
main.cpp:(.text+0xaf): undefined reference to `PoDoFo::PdfVecObjects::PdfVecObjects()'
main.cpp:(.text+0xc7): undefined reference to `PoDoFo::PdfParser::PdfParser(PoDoFo::PdfVecObjects*)'
collect2: ld returned 1 exit status


Here's (parts of) my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <QFileDialog>
#include <podofo/base/PdfParser.h>
#include <podofo/base/PdfVecObjects.h>

[...]

void readPDF(QFile file)
{
    PoDoFo::PdfVecObjects *pdfVecObject = new typename PoDoFo::PdfVecObjects::PdfVecObjects;
    PoDoFo::PdfParser *parser = new typename PoDoFo::PdfParser::PdfParser(pdfVecObject);
[...]
}
   

I'm pretty sure the rest of the code has nothing to do with it.

So.. How am I reffering to the PoDoFo classes wrong?
Jun 27, 2012 at 8:31pm
Also, I'm using the IDE "Qt Creator" and I haven't modified the compiler flags.
Jun 27, 2012 at 8:32pm
You are missing some library file probably. Are you sure you are linking to the PoDoFo library correctly?
Jun 27, 2012 at 8:46pm
I'm not totally sure, but I think so. If I write something else (like "/podofo/base/foo.h") I get another error message:
../schema/main.cpp:6:34: fatal error: podofo/base/foo.h: No such file or directory

And both header files exist under /usr/include/podofo/base/.
Last edited on Jun 27, 2012 at 11:16pm
Jun 27, 2012 at 9:13pm
I think it finds the header but not the object file which it's supposed to link. I have no idea where the object files for podofo are.
Jun 27, 2012 at 10:22pm
It's not "WHERE". It's "WHICH". You need to know their name. Then linking them is quite easy, you just have to find a Linking List in your IDE.
Jun 27, 2012 at 11:16pm
Well isn't the name the same as the header name? Where can I find a "Linking list" in Qt Creator?
Jun 27, 2012 at 11:17pm
Jun 28, 2012 at 6:10am
$ g++ main.o -lpodofo -o program.bin
You may need to specify the library path with -L
Jun 28, 2012 at 9:51pm
That worked! Thank you guys!

Since I use qt creator which uses qmake, and not g++, I found out I needed to add "LIBS += -L/path/to/sfml -lsfmlsystem -lsfmlwindow" in myproject.pro
Topic archived. No new replies allowed.