V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chenqh
V2EX  ›  Android

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

  •  
  •   chenqh · 2018-09-20 14:49:23 +08:00 · 4606 次点击
    这是一个创建于 2017 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境: 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 条回复    2018-09-21 09:35:45 +08:00
    andrewhxism
        1
    andrewhxism  
       2018-09-20 15:09:00 +08:00   ❤️ 2
    是你的问题
    你要指定 elf.h 的路径,而这个路径显然不在标准库的路径里,不能使用尖括号。
    假设你有 elf.h,及对应的库文件(.a .o .lib .so )等,使用#include "/home/elf.h",并在链接时加上前面说的 lib 即可编译通过并运行。
    chenqh
        2
    chenqh  
    OP
       2018-09-20 15:10:11 +08:00
    @andrewhxism 这个 elf 在 windows 是通过什么安装的?
    andrewhxism
        3
    andrewhxism  
       2018-09-20 15:11:03 +08:00   ❤️ 1
    @chenqh 我哪知道~
    kokutou
        4
    kokutou  
       2018-09-20 15:18:33 +08:00   ❤️ 1
    搞 c 建议 virtualBox 虚拟机装个 Ubuntu,很多问题都不会碰到。
    chenqh
        5
    chenqh  
    OP
       2018-09-20 15:22:34 +08:00
    @kokutou 我是学习 androidC
    Deville
        6
    Deville  
       2018-09-20 15:22:38 +08:00   ❤️ 1
    一定是锤子的问题
    chenqh
        7
    chenqh  
    OP
       2018-09-20 15:23:09 +08:00
    @andrewhxism 知道是怎么回事了,我 gcc 不对,我用的是 mingmw 的那个 gcc,所以出了问题。。
    aa514758835
        8
    aa514758835  
       2018-09-20 16:17:21 +08:00   ❤️ 1
    应该是那个头文件是不存在或者名字错了吧~
    misaka19000
        9
    misaka19000  
       2018-09-20 16:39:01 +08:00   ❤️ 1
    elf 听起来应该在 Linux 环境中使用
    F1024
        10
    F1024  
       2018-09-20 16:49:45 +08:00   ❤️ 1
    elf.h: No such file or directory
    lackywind
        11
    lackywind  
       2018-09-20 17:05:52 +08:00   ❤️ 1
    elf 就是 android so 库的文件结构,linux 下的 bin 也是 elf,先自己环境看看有没有这个头文件喽,没有就去网上拉个丢进目录,比如这种
    https://android.googlesource.com/platform/art/+/master/runtime/elf.h
    nealwx
        12
    nealwx  
       2018-09-20 17:06:11 +08:00 via iPhone   ❤️ 1
    你要是放在 Android 上跑,你得配交叉编译环境的吧
    sxsexe
        13
    sxsexe  
       2018-09-20 17:14:29 +08:00   ❤️ 1
    makefile 里先把路径 include 进来吧
    flynaj
        14
    flynaj  
       2018-09-20 18:48:07 +08:00   ❤️ 1
    建议你好好学习一下 c,你连基本知识都不清楚
    socradi
        15
    socradi  
       2018-09-21 09:35:45 +08:00   ❤️ 1
    我这里是可以的,你检查一下编译器是否装好。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2916 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.