交叉编译 -sh: ./xxx: not found 的问题 - 身份也没凭没据

ZQQH 2021-11-11 原文


交叉编译 -sh: ./xxx: not found 的问题

1.环境介绍

  开发板:荔枝派

  交叉编译器:arm-linux-gnueabihf-

  内核版本:linux-4.14-y

2.问题分析

执行交叉编译,生成的文件在班子内显示

# ./mygpio 
-sh: ./mygpio: not found

  (1).一般可能是没有执行权限

  (2).缺少库文件

3.解决办法

我的问题可能是2。所以

zqh@linux:~/lichee/Driver learn/LED$ arm-linux-gnueabihf-readelf -e mygpio 
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2\'s complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x10434
  Start of program headers:          52 (bytes into file)
  Start of section headers:          15048 (bytes into file)
  Flags:                             0x5000200, Version5 EABI, soft-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         36
  Section header string table index: 33

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00010154 000154 000013 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            00010168 000168 000020 00   A  0   0  4
  [ 3] .note.gnu.build-i NOTE            00010188 000188 000024 00   A  0   0  4
  [ 4] .gnu.hash         GNU_HASH        000101ac 0001ac 000048 04   A  5   0  4
  [ 5] .dynsym           DYNSYM          000101f4 0001f4 0000b0 10   A  6   1  4
  [ 6] .dynstr           STRTAB          000102a4 0002a4 000067 00   A  0   0  1
  [ 7] .gnu.version      VERSYM          0001030c 00030c 000016 02   A  5   0  2
  [ 8] .gnu.version_r    VERNEED         00010324 000324 000020 00   A  6   1  4
  [ 9] .rel.dyn          REL             00010344 000344 000008 08   A  5   0  4
  [10] .rel.plt          REL             0001034c 00034c 000050 08  AI  5  22  4
  [11] .init             PROGBITS        0001039c 00039c 00000c 00  AX  0   0  4
  [12] .plt              PROGBITS        000103a8 0003a8 00008c 04  AX  0   0  4
  [13] .text             PROGBITS        00010434 000434 00057c 00  AX  0   0  4
  [14] .fini             PROGBITS        000109b0 0009b0 000008 00  AX  0   0  4
  [15] .rodata           PROGBITS        000109b8 0009b8 000083 00   A  0   0  4
  [16] .ARM.exidx        ARM_EXIDX       00010a3c 000a3c 000008 00  AL 13   0  4
  [17] .eh_frame         PROGBITS        00010a44 000a44 000004 00   A  0   0  4
  [18] .init_array       INIT_ARRAY      00020f0c 000f0c 000004 00  WA  0   0  4
  [19] .fini_array       FINI_ARRAY      00020f10 000f10 000004 00  WA  0   0  4
  [20] .jcr              PROGBITS        00020f14 000f14 000004 00  WA  0   0  4
  [21] .dynamic          DYNAMIC         00020f18 000f18 0000e8 08  WA  6   0  4
  [22] .got              PROGBITS        00021000 001000 000038 04  WA  0   0  4
  [23] .data             PROGBITS        00021038 001038 000008 00  WA  0   0  4
  [24] .bss              NOBITS          00021040 001040 00000c 00  WA  0   0  4
  [25] .comment          PROGBITS        00000000 001040 00003b 01  MS  0   0  1
  [26] .ARM.attributes   ARM_ATTRIBUTES  00000000 00107b 00002a 00      0   0  1
  [27] .debug_aranges    PROGBITS        00000000 0010a5 000040 00      0   0  1
  [28] .debug_info       PROGBITS        00000000 0010e5 00089b 00      0   0  1
  [29] .debug_abbrev     PROGBITS        00000000 001980 0001a2 00      0   0  1
  [30] .debug_line       PROGBITS        00000000 001b22 0000ee 00      0   0  1
  [31] .debug_frame      PROGBITS        00000000 001c10 00009c 00      0   0  4
  [32] .debug_str        PROGBITS        00000000 001cac 001040 01  MS  0   0  1
  [33] .shstrtab         STRTAB          00000000 003970 000157 00      0   0  1
  [34] .symtab           SYMTAB          00000000 002cec 000890 10     35 101  4
  [35] .strtab           STRTAB          00000000 00357c 0003f4 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  EXIDX          0x000a3c 0x00010a3c 0x00010a3c 0x00008 0x00008 R   0x4
  PHDR           0x000034 0x00010034 0x00010034 0x00120 0x00120 R E 0x4
  INTERP         0x000154 0x00010154 0x00010154 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.3]
  LOAD           0x000000 0x00010000 0x00010000 0x00a48 0x00a48 R E 0x10000
  LOAD           0x000f0c 0x00020f0c 0x00020f0c 0x00134 0x00140 RW  0x10000
  DYNAMIC        0x000f18 0x00020f18 0x00020f18 0x000e8 0x000e8 RW  0x4
  NOTE           0x000168 0x00010168 0x00010168 0x00044 0x00044 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x000f0c 0x00020f0c 0x00020f0c 0x000f4 0x000f4 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     .ARM.exidx 
   01     
   02     .interp 
   03     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx .eh_frame 
   04     .init_array .fini_array .jcr .dynamic .got .data .bss 
   05     .dynamic 
   06     .note.ABI-tag .note.gnu.build-id 
   07     
   08     .init_array .fini_array .jcr .dynamic

看到我高亮的那一行:

[Requesting program interpreter: /lib/ld-linux.so.3]
接着我去板子里面找。发现并没有。所以我尝试将其拷贝到开发板的/lib/下。

接下来
./mygpio: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

看来还缺少一个库。然后我把这个库放到板子里之后我的文件系统就坏掉了。。。

============================================分割线=====================================

1.发现问题

原来是Makefile的问题,我重新写了makefile

TARGET        = myGPIO    #可执行文件名称

########################编译参数############################
CC            = arm-linux-gnueabihf-gcc 
CXX           = arm-linux-gnueabihf-g++ 
DEFINES       = 
CFLAGS        = -pipe -g -Wall -W -fPIE $(DEFINES)
CXXFLAGS      = -pipe -g -Wall -W -fPIE $(DEFINES)
INCPATH       = -I. 


########################编译文件############################
SOURCES       = ./main.c ./gpio.c
OBJECTS       = main.o gpio.o

$(TARGET) : $(OBJECTS)
        $(CC) -o $(TARGET) $(OBJECTS)
main.o : main.c gpio.h
        $(CC) $(include) $(CFLAGS) -c main.c 
gpio.o : gpio.c gpio.h 
        $(CC) $(include) $(CFLAGS) -c gpio.c 
clean :
        rm $(TARGET) $(OBJECTS)

这样make就ok了。

 

 
发表于
2018-03-09 21:38 
身份也没凭没据 
阅读(2451
评论(0
编辑 
收藏 
举报

 

版权声明:本文为ZQQH原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ZQQH/p/8533631.html

交叉编译 -sh: ./xxx: not found 的问题 - 身份也没凭没据的更多相关文章

  1. Android测试(四):Instrumented 单元测试 – 虫师

    Android测试(四):Instrumented 单元测试 2018-01-06 10:19  虫师  阅读 […]...

  2. Linux中配置Java开发环境 – 老九君

    Linux中配置Java开发环境 2019-09-30 14:35  老九君  阅读(15319)  评论(0 […]...

  3. 设计模式 – 工厂模式

    工厂模式是创建型模式之一,其主要功能都是帮助我们把对象的实例化部分分离出来,降低系统中代码耦合度,增强了系统的 […]...

  4. 在Photoshop中实现将Roughness贴图放入Metalic贴图的Alpha通道中 – 苏帕

    在Photoshop中实现将Roughness贴图放入Metalic贴图的Alpha通道中 一万年过去了,我终 […]...

  5. 提高打字速度https://www.zhihu.com/question/21509685 – 毛无语666

    提高打字速度https://www.zhihu.com/question/21509685 先简单的回忆下手指 […]...

  6. MuleSoft系列(三)- 使用API设计器通过RAML定义API

    在MuleSoft中,创建Application的方式有三种 Flow Designer:用于构建连接系统并使 […]...

  7. Windows-查看端口号被那个进程占用 – francislee

    Windows-查看端口号被那个进程占用 适用场景: 需要查看或者核对某个进程使用的端口号是否正确 操作: 1 […]...

  8. Spring AOP 源码分析 – 拦截器链的执行过程

    1.简介 本篇文章是 AOP 源码分析系列文章的最后一篇文章,在前面的两篇文章中,我分别介绍了 Spring […]...

随机推荐

  1. 机器学习降维之主成分分析

    1. 主成分基本思想 主成分基本思想:在主成分分析中,首先对给定数据进行规范化,使得数据每一个变量的平均值维0 […]...

  2. Linux常用压缩命令

    Linux常见的压缩格式有.zip、.gz、.bz2、.tar、.tar.gz、.tar.bz2;常用的压缩命令有zip、tar。zip常用命令# 压缩文件zip file.zip file_name# 压缩文件夹(包含子目录)z...

  3. N2N windows下编译安装文件

    n2n安装 n2n原理编译版下载,可直接使用:windows下vpn客户端 n2n_v2_linux_x64  […]...

  4. [App Store Connect帮助]六、测试 Beta 版本(4.4) 管理 Beta 版构建版本:停止测试构建版本

    热烈欢迎,请直接点击!!! 进入博主App Store主页,下载使用各个作品!!! 注:博主将坚持每月上线一个 […]...

  5. Mybatis工作原理

    近来想写一个mybatis的分页插件,但是在写插件之前肯定要了解一下mybatis具体的工作原理吧,于是边参考 […]...

  6. 带着萌新看springboot源码09(springboot+jdbc)

    带着萌新看springboot源码09(springboot+jdbc)   emmm…..常规开 […]...

  7. LinkedHashMap如何保证顺序性

    一. 前言 先看一个例子,我们想在页面展示一周内的消费变化情况,用echarts面积图进行展示。如下: 我们在 […]...

  8. 就因为加了Lombok的@Accessors(chain = true),bean拷贝工具类不干活了

    前言 这次新建了一个工程,因为 Lombok 用得很习惯,但以前的话,一般只用了@Data,@AllArgsC […]...

展开目录

目录导航