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

17 篇文章 0 订阅

这个不需要什么解释吧;

2018.6.1 增加新内容<<<<<<<<<<<<<<<

:其实这是 API19之前的内存地址随机话的要求;

后来的api版本强制要求了PIE了.所以根本上不用加这个了如果你的target api 版本>19的话

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

android.mk 文件

LOCAL_CFLAGS += -fPIE

LOCAL_LDFLAGS += -fPIE -pie

CMAKE

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie")

下边是一个executeable的例子:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/${ANDROID_ABI}")


SET(SRC_LIST
    websever.cpp
    mns_handler.cpp
    mns/mns_client.cpp
    mns/mns_common_tool.cpp
    mns/mns_exception.cpp
    mns/mns_network_tool.cpp
    mns/mns_protocol.cpp
    mns/mns_utils.cpp
    mns/pugiconfig.hpp
    mns/pugixml.cpp
    SHA1.cpp
    HMAC_SHA1.cpp

)

add_executable(httpsvr ${SRC_LIST})


target_include_directories(httpsvr PRIVATE
                                include/curl/
                                include/
                                mns/
                                ${CMAKE_SOURCE_DIR}/)

find_library(log-lib log)
find_library(z-lib z)



add_library(libcurl STATIC IMPORTED)
set_target_properties(libcurl PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libcurl.a)


target_link_libraries(httpsvr libcurl ${z-lib})


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值