环境: 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
求大佬们指点下我该怎么解决?
![]() |
1
andrewhxism 2018-09-20 15:09:00 +08:00 ![]() 是你的问题
你要指定 elf.h 的路径,而这个路径显然不在标准库的路径里,不能使用尖括号。 假设你有 elf.h,及对应的库文件(.a .o .lib .so )等,使用#include "/home/elf.h",并在链接时加上前面说的 lib 即可编译通过并运行。 |
2
chenqh OP @andrewhxism 这个 elf 在 windows 是通过什么安装的?
|
![]() |
3
andrewhxism 2018-09-20 15:11:03 +08:00 ![]() @chenqh 我哪知道~
|
![]() |
4
kokutou 2018-09-20 15:18:33 +08:00 ![]() 搞 c 建议 virtualBox 虚拟机装个 Ubuntu,很多问题都不会碰到。
|
6
Deville 2018-09-20 15:22:38 +08:00 ![]() 一定是锤子的问题
|
7
chenqh OP @andrewhxism 知道是怎么回事了,我 gcc 不对,我用的是 mingmw 的那个 gcc,所以出了问题。。
|
8
aa514758835 2018-09-20 16:17:21 +08:00 ![]() 应该是那个头文件是不存在或者名字错了吧~
|
![]() |
9
misaka19000 2018-09-20 16:39:01 +08:00 ![]() elf 听起来应该在 Linux 环境中使用
|
![]() |
10
F1024 2018-09-20 16:49:45 +08:00 ![]() elf.h: No such file or directory
|
![]() |
11
lackywind 2018-09-20 17:05:52 +08:00 ![]() elf 就是 android so 库的文件结构,linux 下的 bin 也是 elf,先自己环境看看有没有这个头文件喽,没有就去网上拉个丢进目录,比如这种
https://android.googlesource.com/platform/art/+/master/runtime/elf.h |
![]() |
12
nealwx 2018-09-20 17:06:11 +08:00 via iPhone ![]() 你要是放在 Android 上跑,你得配交叉编译环境的吧
|
![]() |
13
sxsexe 2018-09-20 17:14:29 +08:00 ![]() makefile 里先把路径 include 进来吧
|
![]() |
14
flynaj 2018-09-20 18:48:07 +08:00 ![]() 建议你好好学习一下 c,你连基本知识都不清楚
|
15
qfpZ2KhNsF23UGbN 2018-09-21 09:35:45 +08:00 ![]() 我这里是可以的,你检查一下编译器是否装好。
|