Android上執行gcc編譯的exe檔案

2021-09-02 23:35:57 字數 1561 閱讀 9032

編譯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

參考

ubuntu 下gcc的編譯執行

一些基本的操作 gcc test.c 將test.c預處理 彙編 編譯並鏈結形成可執行檔案test gcc test.c o test o用來指定輸出檔案的檔名 gcc e test.c o test.i 將test.c預處理輸出test.i檔案 gcc c test.s 將彙編輸出檔案test.s...

GCC執行過程 gcc編譯靜態庫和動態庫

1 預處理階段 這個階段主要是處理原始檔中的 ifdef include和 define命令 命令 gcc e c o i 2 編譯階段 輸入的是中間檔案 i,編譯後生成組合語言檔案 s 命令 gcc s i o s 3 彙編階段 輸入的是彙編檔案 s,輸出的轉換生成的機器語言 o 命令 gcc c...

gcc下c c 程式編譯 執行命令

一 基本命令 c編譯 執行 gcc wall g o desktop test desktop test.c desktop test c 編譯 執行 g desktop c test.cpp o desktop c test.exe desktop c test.exe 注意具體目錄 二 新增警告...