怎样编译android版gcc,Android上运行gcc编译的exe文件

编译c程序生成可执行文件

user@thundersoft:~/data/work/media-ctl-97077a7$ gcc  main.c  options.c  v4l2subdev.c mediactl.c -o media.exe

push到手机中运行提示没有这个文件或者目录

user@thundersoft:~/data/work/media-ctl-97077a7$ adb push media.exe  system/bin

leaf_hill:/system/bin # media.exe

/system/bin/sh: /system/bin/media.exe: No such file or directory

网上找到原因是因为程序使用的是动态链接方式编译的,而Android和Ubuntu的链接库文件路径不同,导致找不到文件

可以用gcc -static命令改用静态链接的方式编译,执行成功。

user@thundersoft:~/data/work/media-ctl-97077a7$ gcc  main.c  options.c  v4l2subdev.c mediactl.c -o media.exe -static

user@thundersoft:~/data/work/media-ctl-97077a7$ adb push media.exe  data/misc/cameraserver

leaf_hill:/data/misc/cameraserver # ./media.exe

./media.exe [options] device

-d, --device dev    Media device name (default: /dev/media0)

-e, --entity name    Print the device name associated with the given entity

-V, --set-v4l2 v4l2    Comma-separated list of formats to setup

--get-v4l2 pad    Print the active format on a given pad

-h, --help        Show verbose help and exit

-i, --interactive    Modify links interactively

-l, --links        Comma-separated list of links descriptors to setup

-p, --print-topology    Print the device topology

--print-dot        Print the device topology as a dot graph

-r, --reset        Reset all links to inactive

-v, --verbose        Be verbose

参考

https://blog..net/kraken5142709/article/details/19766759

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值