How to reduce gdnative plugin size?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By supper_raptor

The size of gdnative plugin for very simple cpp script is very large ( > 70 mb).
How to reduce it and is it safe to use -s and -g flags ?

:bust_in_silhouette: Reply From: abrajam

One way could be compile for release instead of debug, but, oh! 70 mb is very very large! maybe you are confusing the dynamic library with the static library which includes all the functions and not just the needed ones, because when I get the dynamic library it only weights 4.7 mb and that is just what it needs to include in the godot project.

I get 4.7 mb for android and 70 mb for linux and windows.

supper_raptor | 2020-06-30 14:22

You are not compiling right, I tried with ndk-build and I have 3.6 mb for the .so library, you are doing something wrong.

abrajam | 2020-07-22 21:44

i have the same problem but my gdnative dynamic dll for windos is 128MB size, im using goot 3.2.2 stable in windows 7 32bits and MingW_64 . i asked here for some hint to reduce c++ bindings static libary size that in my case is about 140MB, because i think there are relationship betwen both sizes and the link phase(im beginer in c++) , so any tip about compilation would be great too.

UPDATE Checkout the scostruct file and add/edit the -strip/-s link flag, i resolved the problem linking manually in Mingw with -s flag and size decreased in 95%, i dont know in VS…

peeterdog | 2020-07-30 22:11

:bust_in_silhouette: Reply From: supper_raptor

Oh fixed after a long time. You need to remove all occurence of -g from SConstruct file and recompile. Now plugin the size is about 4-5 mb.