Tuesday, June 12, 2012

MuPDF Android Library Build

Today I was able to successfully build MuPDF library on Windows 7 platform using Cygwin. I'll explain each and every step here.

1. Android SDK should be installed.

2. Android NDK should be installed

Just download android NDK here http://developer.android.com/sdk/ndk/index.html and extract it to a directory with no spaces in the name.

3. You need to install Cygwin latest version. download the setup.exe from http://cygwin.com/install.html and follow instructions here. do not skip a single step. Instructions :  http://vmerror.com/?p=133

4. Download MuPDF source zip file and third-party zip file here http://code.google.com/p/mupdf/downloads/list

5. Extract your mupdf source folder somewhere in your hard disk (path must not contain any spaces)

6. Create a folder named 'thirdparty' in the mupdf source folder you have extracted. It should be in the same level of 'android', 'apps', 'fitz', 'win32' etc. and extract downloaded thirdparty zip file directly under created folder.

7. You need to have Visual studio installed. if not you can download trial version here : http://www.microsoft.com/en-us/download/details.aspx?id=12752

Download and install it properly.

8. Go to mupdf source folder, open win32 folder and double click generated.vcproj

then it will open with visual studio.

9. In visual studio just run the c++ application. no need to have any visual studio or c++ knowledge. just press green arrow button (run button)

10. If everything goes ok, it should create a folder inside mupdf source. the folder name is 'generated' and it should contain some header files (.h files)

11. Open Cygwin console,(just double click cygwin installation short-cut) and type following command and enter.

 

cd /cygdrive/<path to mupdf sorce folder/android

ex. cd /cygdrive/c/mupdf-1.0-source/android

then

/cygdrive/<path to ndk installation>/ndk-build

ex. /cygdrive/c/ndk/ndk-build

 

Cheerz... thats all. now you have built your mupdf library and what you can do is, create an Android application using mupdf android source (inside android folder) run it and see...

you can create a library project and include it anywhere you need.

 

3 comments:

  1. Thanks dude...you made my day..i tried same from last two days.

    ReplyDelete
  2. Hi,

    I follow each and every step and end up with the following error, when build muPdf as library project:

    **** Build of configuration Default for project MupdfLib ****

    D:\AndroidSetup\adt-bundle-windows-x86-20130729\android-ndk-r9-windows-x86\android-ndk-r9\ndk-build.cmd all
    Android NDK: WARNING:jni/Android.mk:mupdfcore: LOCAL_LDLIBS is always ignored for static libraries
    "Compile thumb : mupdf <= mupdf.c
    jni/mupdf.c:15:24: fatal error: mupdf/fitz.h: No such file or directory
    compilation terminated.
    make: *** [obj/local/armeabi-v7a/objs/mupdf/mupdf.o] Error 1

    **** Build Finished ****

    Please,help me out!!!

    ReplyDelete
  3. hi..I follow ur all steps..But when i run android program,Its open blank window?bt y its happed??do u suggest me or help me??

    ReplyDelete