2

I have libfitz.a and libmupdf.a in /usr/local/lib (previously compiled). then I included the headers:

#include <fitz.h>
#include <mupdf.h>

then I put:

INCLUDEPATH  +=/home/pc/sviluppo/mupdf-0.9
INCLUDEPATH  +=/home/pc/sviluppo/mupdf-0.9/fitz
INCLUDEPATH  +=/home/pc/sviluppo/mupdf-0.9/pdf

LIBS         += -L/usr/local/lib -lfitz
LIBS         += -L/usr/local/lib -lmupdf

in .pro file, but my program just reaches to types in the headers, not the library. The error is

/.../mainwindow.cpp:-1: error: undefined reference to `pdf_open_xref(pdf_xref_s**, char const*, char*)'

What's wrong?

tshepang
  • 12,111
  • 21
  • 91
  • 136
P5music
  • 3,197
  • 2
  • 32
  • 81
  • How and/or for which architecture (32bit/64bit) did you install Qt and mupdf ? – alexisdm Sep 13 '11 at 15:29
  • I have 32bit system, I succesfully compiled mupdf because tools are available; I successfully used poppler in Qt-4; what's wrong now? – P5music Sep 14 '11 at 07:39

1 Answers1

1

This is a C library, and they didn't use extern "C" to allow the headers to be included easily in C++.
So you have to do it yourself:

extern "C" {
    #include <fitz.h>
    #include <mupdf.h>
}

According to mupdf MakeFile, you should put the libraries in that order in your .pro (the more dependent static library should be placed before its dependencies):

LIBS         += -L/usr/local/lib -lmupdf -lfitz
LIBS         += -lfreetype -ljbig2dec -ljpeg -lopenjpeg -lz -lm
alexisdm
  • 29,448
  • 6
  • 64
  • 99
  • thx @alexisdm now it seems that qt-creator is trying to compile all mupdf so many errors are issued (>1000). For example the first error is /usr/local/lib/libmupdf.a(pdf_page.o):-1: In function `pdf_find_page_number': It also seems that it encounters errors when reading from usr/local/lib libraries like libmupdf.a then others errors like /home/pc/sviluppo/mupdf-0.9/pdf/pdf_page.c:36: error: undefined reference to `fz_dict_gets' – P5music Sep 14 '11 at 12:43
  • @P5music These are linker errors, try what I added to the answer. – alexisdm Sep 14 '11 at 13:07