simple2025
0D
V2EX  ›  Android

遇到一个不知道是 C 语言还是 android 的问题

  •  
  •   simple2025 · Sep 20, 2018 · 14293 views
    This topic created in 2985 days ago, the information mentioned may be changed or developed.

    环境: win10, cygwin

    运行make命令之后

    gcc -o shellAdder1 shellAdder1.c
    shellAdder1.c:3:17: fatal error: elf.h: No such file or directory
     #include <elf.h>
                     ^
    compilation terminated.
    make: *** [makefile:2: all] Error 1
    

    求大佬们指点下我该怎么解决?

    15 replies  •  2018-09-21 09:35:45 +08:00
    andrewhxism
    andrewhxism
    Sep 20, 2018❤️2
    1
    是你的问题
    你要指定 elf.h 的路径,而这个路径显然不在标准库的路径里,不能使用尖括号。
    假设你有 elf.h,及对应的库文件(.a .o .lib .so )等,使用#include "/home/elf.h",并在链接时加上前面说的 lib 即可编译通过并运行。
    simple2025
    simple2025
    OP
    Sep 20, 2018
    2
    @andrewhxism 这个 elf 在 windows 是通过什么安装的?
    andrewhxism
    andrewhxism
    Sep 20, 2018❤️1
    3
    @chenqh 我哪知道~
    kokutou
    kokutou
    Sep 20, 2018❤️1
    4
    搞 c 建议 virtualBox 虚拟机装个 Ubuntu,很多问题都不会碰到。
    simple2025
    simple2025
    OP
    Sep 20, 2018
    5
    @kokutou 我是学习 androidC
    Deville
    Deville
    Sep 20, 2018❤️1
    6
    一定是锤子的问题
    simple2025
    simple2025
    OP
    Sep 20, 2018
    7
    @andrewhxism 知道是怎么回事了,我 gcc 不对,我用的是 mingmw 的那个 gcc,所以出了问题。。
    aa514758835
    aa514758835
    Sep 20, 2018❤️1
    8
    应该是那个头文件是不存在或者名字错了吧~
    misaka19000
    misaka19000
    Sep 20, 2018❤️1
    9
    elf 听起来应该在 Linux 环境中使用
    F1024
    F1024
    Sep 20, 2018❤️1
    10
    elf.h: No such file or directory
    lackywind
    lackywind
    Sep 20, 2018❤️1
    11
    elf 就是 android so 库的文件结构,linux 下的 bin 也是 elf,先自己环境看看有没有这个头文件喽,没有就去网上拉个丢进目录,比如这种
    https://android.googlesource.com/platform/art/+/master/runtime/elf.h
    nealwx
    nealwx
    Sep 20, 2018 via iPhone❤️1
    12
    你要是放在 Android 上跑,你得配交叉编译环境的吧
    sxsexe
    sxsexe
    Sep 20, 2018❤️1
    13
    makefile 里先把路径 include 进来吧
    flynaj
    flynaj
    Sep 20, 2018❤️1
    14
    建议你好好学习一下 c,你连基本知识都不清楚
    qfpZ2KhNsF23UGbN
    qfpZ2KhNsF23UGbN
    Sep 21, 2018❤️1
    15
    我这里是可以的,你检查一下编译器是否装好。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 05:40 · PVG 13:40 · LAX 21:40 · JFK 00:40
    ♥ Do have faith in what you're doing.