Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need -static option to compile native android applications

I was trying to build a native android application. When I tried to run it, I got an error this file does not exist. With little bit google, I found I need put -static option in compilation. I did so and it worked. But I wonder why is this options is required? Is it anything to do with cross compilation?

like image 519
agent.smith Avatar asked Nov 27 '25 06:11

agent.smith


1 Answers

The option -static produces a statically linked binary without any dependencies to shared libraries. This is done if the system on which the linking takes place uses different libraries as the system on which the binary will run. In most cases this is a hack to avoid problems with incompatible libraries. The disadvantage of a statically linked binary is, that it is much bigger than a shared linked one and it uses much more memory. Generally it is better to create a proper build environment, which makes it possible to dynamically link the shared libraries.

like image 68
ceving Avatar answered Nov 29 '25 19:11

ceving



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!