MuPDF在iOS平台的編譯

來源:互聯網
上載者:User
iOS平台雖然提供了方便的PDF渲染介面,但對於簡體中文字型的支援並不完整,容易發生亂碼。即使在iOS 5.0中有了一定的改善,但還是存在亂碼問題。MuPDF是一款開源的PDF閱讀器,渲染效率相對較高,並且對簡體中文字型的支援也很好。官網:http://www.mupdf.com/下載並解壓縮MuPDF的源碼後,開啟Makerules檔案,查看相關編譯規則,支援平台有不少,但是沒有mac編譯iOS平台的規則,於是添加相關規則。模擬器i386規則: CC = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2AR = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/arCPP = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cppCFLAGS += -arch i386 -m32 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -mmacosx-version-min=10.5 -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/include/
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdkLDFLAGS +=-arch i386 -m32 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -Wl,-dead_strip -mmacosx-version-min=10.5CROSSCOMPILE=yesNOX11=yes真機armv6規則:CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2AR = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arCPP = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cppCFLAGS += -arch armv6 -pipe -mdynamic-no-pic -std=gnu99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.2 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/libxml2
-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdkLDFLAGS += -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -miphoneos-version-min=4.2CROSSCOMPILE=yesNOX11=yes真機armv7規則:CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2AR = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arCPP = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cppCFLAGS += -arch armv7 -pipe -mdynamic-no-pic -std=gnu99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=4.2 -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/libxml2
-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdkLDFLAGS += -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -miphoneos-version-min=4.2CROSSCOMPILE=yesNOX11=yes執行make libs命令,在目錄下產生*.a庫檔案。在過程中遇見過一些問題:產生庫檔案後,在工程中調用相關介面,提示錯誤:ld: symbol(s) not found 經過排查,原來犯了個小錯誤:MuPDF是使用C編譯器編譯,但是工程使用c++編譯,所以需要在引用檔案添加extern "C" {    #include <fitz.h>    #include <mupdf.h>}編譯真機版庫檔案時候,提示錯誤:‘asm’ undeclared (first use in this function)進過排查,編譯參數設定錯誤,將-std=c99換成-std=gnu99就成功了。詳情可見:What's the difference between GNU99 and C99 (Clang)?

http://stackoverflow.com/questions/5313536/whats-the-difference-between-gnu99-and-c99-clang

終於木有亂碼了:
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.