开发者

referencing mupdf in Qt4 project

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-开发者_C百科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?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜