Speed up cocos2dx 3.x by using prebuilt libs (Win32)
- Generate lib cocos2dx for project Win32
Open CMD and run command :
cocos gen-libs -p win32 — vs 2015 -m debug
It will take about 5 minutes to completed. When it completed, libs and dll file s are generated following path (Ex..\cocos2d-x-3.14.1\prebuilt\win32)
- Replace property sheet in project Win32
Open project Win32 on Visual Studio 2015.
Open Property Manager (View->Other Windows->Property Manager). Delete “cocos2d_headers”, “cocos2dx”
Add new property sheet: Right click on Debug in Property Manager and select “Add existing property sheet”. Go to path “..\cocos2d-x-3.14.1\cocos\2d” and add 2 files “cocos2d_headers.pros”, “cocos2dx.pros”
Double click on property “cocos2dx”, and go to Linker -> Input, at Additional Dependencies -> Edit and delete “libbox2d.lib”, “libSpine.lib” if exist. Save and Apply.
***If don’t have 2 files .lib above you can skip and move to next step.
- Change library path
Right click on our main project game coco2dx -> Properties -> VC++ Directories.
At “Lirary Directories” choose arrow and click Edit and Add new path which libs and dlls generated before. Ex: “..\cocos2d-x-3.14.1\prebuilt\win32”
- Add dependencies files
In Properties windows of project, choose Linker -> Input. Select Additional Dependencies and choose Edit
Add the follow libs name : “libcocos2d_2015.lib”, “libbox2d_2015.lib”, “libbullet_2015.lib”, “librecast_2015.lib”, “libSpine_2015.lib”
- Adding a debugging environment ( environment variable )
In Properties windows of project, choose Debuging->Environment. Go Edit and add path to folder prebuilt. Ex: “PATH=..\cocos2d-x-3.14.1\prebuilt\win32” (Remeber you must have prefix : “PATH=”)
- Remove unnecessary projects from solution
Select and remove “libcocos2d”, “libbullet”, “librecast”, “libSpine”, “libbox2d”
Done! Let run and check new speed when build project :)