近期有一個用到了zlip的壓縮和lua的dll需要編譯到安卓平臺下用,就使用SWIG做了轉換,然后使用QT MinGW編譯so文件.
swig轉換很順利.沒有碰到什么問題,但是編譯so確碰到了一些問題,網上查找相關資料也不是特別多,零零散散的,導致解決問題也不是很順利,在此做下記錄.
編譯單純得zlip的源碼沒啥問題,但是因為我里面用到了minizip來操作文件,它對于linux的編譯就沒有做很好的適配,將其的代碼加入QT工程里面編譯,會報如下錯誤:
/ioapi.c:127: error: undefined reference to 'fopen64'
/ioapi.c:157: error: undefined reference to 'ftello64'
/ioapi.c:203: error: undefined reference to 'fseeko64'
都是來自ioapi.c的三個函數,這里找不到對應的函數,在Linux里面其對應的是沒有64 的函數 也就是將其加宏控制
#ifdef _WINDLL#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)#define FTELLO_FUNC(stream) ftello64(stream)#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)#else#define FOPEN_FUNC(filename, mode) fopen(filename, mode)#define FTELLO_FUNC(stream) ftello(stream)#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)#endif
這樣就可以編譯通過了,也不影響windows端的編譯.
然后是lua5.1.4的編譯,
其在llex.c 的第181的localeconv()函數會報錯,找不到此函數,這個返回包含本地數字及貨幣信息格式的數組,具體有啥用我也還不太清楚,我將其改為NULL,
然后183行的decimal_point也會沒有,在Linux里面其實就是點,所以只需改為如下:
#ifdef _WINDLL struct lconv *cv = localeconv(); char old = ls->decpoint; ls->decpoint = (cv ? cv->[0] : '.');#else struct lconv *cv = NULL; char old = ls->decpoint; ls->decpoint = '.';#endif
即可編譯通過,經測試我用到的的功能也沒有受到影響.
新聞熱點
疑難解答