简体   繁体   中英

c program binary cannot run in sh

I have cross-compiled an executable from c code for an arm-based embedded system. When I execute the binary in the embedded system, it gives the following error:

line 1: syntax error: unexpected word (expecting ")")

I searched around, and figured out it is because the embedded system (some version of Linux) I am using does not have bash but only sh . Is it possible to make my compiled binary executable using sh , without installing bash in it (which is troublesome)?

Binaries are not built for the shell program. They are built for a particular architecture and OS environment. All shell does is, fork() a child process and calls exec() . So it won't matter whether your host machine is having bash or sh . Just make sure that binary is for the correct architecture and the machine. And you are indeed executing the binary, not the source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM