For example I have several Cocos2d-x C++ project for each project I want to use different set of libraries and integrated third party SDK’s. How to deal with it?
If I compile libraries cocos gen-libs
they get compiled automatically in downloaded Cocos2d-x main folder.
Should I duplicate this folder or I can use coco2d folder generated by command: cocos new …
for other projects?
I was trying to target for pre-compiled library specific project generated coco2d folder, but it failed because script was trying to compile also LUA & JS libraries(which not exist in that cocos2d folder) and I using C++ code.
So what is the best way to have multiple sets or precompiled libraries?
So, I use the Cocos app (when a release is final, 3.7, 38 etc) and download the pre-built libraries through that. I change my path variable when these change and when I run cocos new... it uses these.
If I want to test between final releases I run the scripts to generate them. If I want to keep versions in time, I duplicate that folder and rename it to the version #.
cocos new will copy the entire cocos2d folder, so you’ll want to remove that folder after your run that command.
Just setup your library search path to reference the /cocos2d/x/root/prebuilt/ folder and then add -lcocos2dMac to your linker flags. This is for g++ and clang on the mac tested with XCode, it will be a little different for Android (or may just require a little extra configuration) and quite a bit different on windows w/visual studio. If you need Lua scripting support make sure to also reference that extra library.
Cocos and RapidGame make this easier. But I’d rather know what’s going on under the hood myself. That’s why I use cocos2d-x for some things since I can change the engine code and make custom prebuilts off a fork of the cocos2d-x repo.
Since these are just binaries you can keep them in /prebuilt/ or you could mode them to your home folder or any other path.
I removed the space from the filename libcocos2d Mac.a but you may figure out how to specify the ‘-l’ linker flag with a file that has a space in its name. You could also rename them to version: libcocos2d-prebuilt-3.7.a or similar.
It sounds interesting approach, I also would like to understand what happening under hood, that why for now not using RapodGame.
I need to understand how this works, like if I add SDKBOX for Android will it be part of precompiled library or it will be somehow linked to project. What kind of files is compiled to library and which not.
@energyy definitely, I haven’t bothered to try SDKBOX just yet as I had the plugins I needed already setup separately. I would imagine SDKBOX could either integrate into your game project or itself could be built into separate static lib or of course could be integrated into a game project where the entire cocos2d source code base is present.
Ideally SDKBOX just adds files to your game project itself since that’s how the SDKs works if you download them separately (at least we’ve done this for our game with Flurry, Google Analytics, Google Admob, and Facebook SDKs).
It’s interesting watching how this engine and others handle game projects. Some use a central engine that your game project references (like prebuilts) and others just dump a full copy of the engine in your project (cocos new).
Note: I tried adding quotes around the library filename -l"cocos2d Mac" and found out that works for filenames with spaces in it. Probably obvious, since bash allows this, but there you go anyway
In our approach we splited cocos2d folder and project files into two different repositories and then added cocos2d repository as submodule for project. So we have all projects related to one cocos2d version and all integrations part was done only in Project files, so each project can have different integrations, but same cocos2d core.
For this approach bad think is compile time, when developer need to recompile cocos2d folder if he cleans project and it takes like 5-10minutes , sometimes if he switches between projects it can take up to 1h only for compile in a day so now checking possibility to use precompiled libs and make coders more happy, less waiting time.
BTW there is debug and release mode for precompiled libs, is there any difference? Can I user for example debug mode compiled libs in release apk or it will crash…