Tutorial: How to Shrink Cocos 2d-x Program Sizes
Have you created a default Cocos 2d-x program only to be shocked by its gargantuan file size? A basic Cocos 2d-x program can be 2.5 gb or more. Highly unacceptable!
The reason for such a large program is that Cocos 2d-x copies the cocos2d libraries into your program’s folder so it can reference them. Rather than allowing it to do so, delete the cocos2d folder from within your program’s directory. Then open a command prompt (on a mac, this would be Terminal. On windows, this needs to be an elevated shell).
How to Open an Elevated Shell on Windows
Go to the Start Menu and in the “Search programs and files” box, type cmd but do not hit enter! Instead, wait for program options to pop up. Right-click on cmd.exe and click Run as Administrator. This will open a command prompt shell with administrator privileges.
In the command prompt, navigate into your program’s directory and type:
Mac: ln -s path_to_cocos2d cocos2d
Windows: mklink /d cocos2d C:\path_to_\cocos2d-x-3.4
where path_to_cocos2d
is the path to the directory containing your cocos2d library files (e.g. C:\Users\HP\Documents\cocos2d-x-3.4)
The above command creates a symbolic link to the cocos2d library rather than redundantly copying it into your program’s folder. Check out the size of your program now. It should have dropped from 2–3 gb to around 200 mb!