• 编译Android控制台程序


    #include <iostream>
    #include <vector>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
    
        for (const string& word : msg){
            cout << word << " ";
        }
        cout << endl;
    }

    # Android.mk
    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    
    LOCAL_CFLAGS += -pie -fPIE
    LOCAL_LDFLAGS += -pie -fPIE
    
    LOCAL_MODULE = hellotest
    ifeq ($(USE_ARM_MODE),1)
    LOCAL_ARM_MODE := arm
    endif
    
    LOCAL_SRC_FILES := ../main.cpp 
    
    LOCAL_C_INCLUDES := $(LOCAL_PATH)
    
    include $(BUILD_EXECUTABLE)
    # Application.mk
    APP_STL := c++_static
    
    # Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices
    APP_ABI := armeabi-v7a
    
    APP_CPPFLAGS := -frtti -std=c++11 -fsigned-char
    APP_LDFLAGS := -latomic
    
    # To solve windows commands char length too long
    APP_SHORT_COMMANDS := true
    
    USE_ARM_MODE := 1
    
    # MUST be careful to modify this manually
    # disable module will speed up compile time, and reduce package size
    USE_GFX_RENDERER := 1
    USE_VIDEO := 1
    USE_WEB_VIEW := 1
    USE_AUDIO := 1
    USE_SOCKET := 1
    USE_SPINE := 1
    USE_DRAGONBONES := 1
    USE_TIFF := 1
    USE_MIDDLEWARE := 1
    USE_PARTICLE := 1
    
    APP_CPPFLAGS += -DUSE_GFX_RENDERER=$(USE_GFX_RENDERER)
    APP_CPPFLAGS += -DUSE_VIDEO=${USE_VIDEO}
    APP_CPPFLAGS += -DUSE_WEB_VIEW=${USE_WEB_VIEW}
    APP_CPPFLAGS += -DUSE_AUDIO=${USE_AUDIO}
    APP_CPPFLAGS += -DUSE_SOCKET=${USE_SOCKET}
    APP_CPPFLAGS += -DUSE_SPINE=${USE_SPINE}
    APP_CPPFLAGS += -DUSE_DRAGONBONES=${USE_DRAGONBONES}
    APP_CPPFLAGS += -DCC_USE_TIFF=${USE_TIFF}
    APP_CPPFLAGS += -DUSE_MIDDLEWARE=${USE_MIDDLEWARE}
    APP_CPPFLAGS += -DUSE_PARTICLE=${USE_PARTICLE}
    
    ifeq ($(NDK_DEBUG),1)
      APP_OPTIM := debug
    else
      APP_CPPFLAGS += -DNDEBUG
      APP_CFLAGS += -DNDEBUG
      APP_OPTIM := release
    endif
    
    # Some Android Simulators don't support SSE instruction, so disable it for x86 arch.
    APP_CPPFLAGS += -U__SSE__
    USE_EDIT_BOX := 1

    编译:NDK_PROJECT_PATH=. ndk-build

    上传到手机: adb push hellotest sdcard

    运行结果:

    经验总结: 一定不要想要这用makefile 或者纯命令编译, 会浪费生命。  浪费了几个小时搞编译环境,真是浪费生命。    直接用ndk-build工具真香

  • 相关阅读:
    php开发_图片验证码
    php开发_php环境搭建
    中序线索二叉树算法
    WPF技巧(1)异步绑定
    WPF技巧(2)绑定到附加属性
    nhibernate 抓取策略
    wpf 控件开发基础(6) 单一容器(Decorator)
    WPF技巧(3)监测属性变更
    Caliburn v2 变更启动初始化
    wpf单容器中的Chrome
  • 原文地址:https://www.cnblogs.com/dzqdzq/p/13514630.html
Copyright © 2020-2023  润新知