码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • android源码添加c/c++工程


    之前参考过许多添加工程的文章,发现都有一个问题,只能单独编译该工程,而且打包时无法自动打包到镜像。

    本文说明一个办法,可以添加工程在make的时候自动打包到镜像。

    一、添加工程源码

           为了简单尝试,直接复制system/core/中的reboot工程目录,命名为hello目录,里面的源码也命名为hello.c。Android.bp和hello.c修改如下:

    1. // Copyright 2013 The Android Open Source Project
    2. package {
    3. default_applicable_licenses: ["Android-Apache-2.0"],
    4. }
    5. cc_binary {
    6. name: "hello",
    7. srcs: ["hello.c"],
    8. shared_libs: [],
    9. cflags: ["-Werror"],
    10. recovery_available: true,
    11. }
    1. /*
    2. * Copyright (C) 2013 The Android Open Source Project
    3. *
    4. * Licensed under the Apache License, Version 2.0 (the "License");
    5. * you may not use this file except in compliance with the License.
    6. * You may obtain a copy of the License at
    7. *
    8. * http://www.apache.org/licenses/LICENSE-2.0
    9. *
    10. * Unless required by applicable law or agreed to in writing, software
    11. * distributed under the License is distributed on an "AS IS" BASIS,
    12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13. * See the License for the specific language governing permissions and
    14. * limitations under the License.
    15. */
    16. #include
    17. #include
    18. #include
    19. #include
    20. int main(int argc, char* argv[]) {
    21. printf("hell %d %s\n", argc, argv[0]);
    22. return 0;
    23. }

    二、以上步骤都可以在其他文章了解到,以下是最关键的一步,添加工程到buid/target/product/base_system.mk中,在该配置文件中加上一句:

    PRODUCT_PACKAGES += hello

    三、编译make -j32

    四、测试:

    烧录镜像到目标开发板

    用adb shell连接上

    用ls /system/bin查看是否有hello文件存在

    用hello命令尝试是否可以执行

    五、祝好运

  • 相关阅读:
    片内总线在cpu扮演什么角色?他为什么能实现高效,不同的CPU为什么采用不同的总线协议?
    tsdx 打包ts项目
    算法查找——二分查找
    【论文复现】QuestEval:《QuestEval: Summarization Asks for Fact-based Evaluation》
    21天打卡挑战学习MySQL——《容器部署MySQL》第三周 第八篇
    brew 下载 nvm 之后,nvm command not found
    掌握百度SEO排名的关键技巧(推动你的网站快速上位)
    美联储加息负面效应外溢
    ROS2初级知识(7):用rqt_console查看日志logs
    背景图片设置
  • 原文地址:https://blog.csdn.net/robitmind/article/details/134324344
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号