NDK編譯可執行檔在Android 中運行顯示error: only position independent executables (PIE) are supported.失敗問題解決辦法。

來源:互聯網
上載者:User

標籤:開啟   顯示   ase   class   and   android   ble   驗證   ace   

由於使用了NDK編譯的可執行檔在應用中調用,在Android 7.0上的運行情況發現,當運行該可執行檔時,報如下錯誤:

error: only position independent executables (PIE) are supported.

PIE這個安全機制從4.1引入,但是Android L之前的系統版本並不會去檢驗可執行檔是否基於PIE編譯出的。因此不會報錯。但是Android L已經開啟驗證,如果調用的可執行檔不是基於PIE方式編譯的,則無法運行。解決辦法非常簡單,在Android.mk中加入如下flag就行。

 

LOCAL_CFLAGS += -pie -fPIELOCAL_LDFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -Wl,--fatal-warnings

 linker_flags = ‘ -Wl,--no-wchar-size-warning ‘,

 

NDK編譯可執行檔在Android 中運行顯示error: only position independent executables (PIE) are supported.失敗問題解決辦法。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.