Cocos new -t binary yields "Template 'binary' is not found"

I have Cocos2d-x 3.13.1 and successfully pre-built the library for every platform. When I do this:

cocos new game -p com.company.game -l cpp -t binary

I get:

Template named 'binary' is not found.
Multiple templates detected!
You can select one via -t arguments.
Or choose one now:

1 default
Select one (input number and press enter):

Any ideas?

I donā€™t believe thereā€™s a pre-built template available yet? There should be, however, and ideally with a selection of the versions you have prebuilt.

Hey,

Iā€™m having the same problem.

Iā€™m following this guide to set it all up. Iā€™m using the head of v3 branch. I basically done:
$ git clone https://github.com/cocos2d/cocos2d-x.git
$ cd cocos2d-x
cocos2d-x $ python download-deps.py
cocos2d-x $ git submodule update --init
cocos2d-x $ ./setup.py
cocos2d-x $ cocos gen-libs -c -ap android-25

I now have three folders under cocos2d-x/prepbuilt:
ios, mac and android

When I now do:
cocos2d-x $ cocos new binary-test -p com.company-binary-test -l cpp -d . -t binary

I get:
"Template named ā€˜binaryā€™ is not found.
Multiple templates detected!
You can select one via -t arguments.
Or choose one now:

1 default
Select one (input number and press enter):"

And looking under template folder there is only one: default.

So how do I generate a project with the prebuilt libraries?

/D

Run

cocos gen-templates

Then the rest of the steps.

Ok thanks. I see now that command is listed at the very end in this guide: http://cocos2d-x.org/docs/editors_and_tools/cocosCLTool/

Maybe it should be listed a bit clearly under ā€œCreating pre-built libraries to use instead of source code.ā€ or under ā€œUsing the pre-built libraries in your projects.ā€ Itā€™s easy to miss.

/D

Itā€™s not really the correct way. It is a deprecated way but still works. There isnā€™t a new way currently.

How can it be deprecated if there is no new way? :smile:

In my understanding there is a way1, when there is a new better way2, the way1 become deprecated.

Deprecated doesnā€™t mean there is a replacement. -t was a Cocos Studio flag and we donā€™t write this product any longer.

Honestly if none of these work well for you Iā€™d suggest learning how to use pre-built libraries for each platform separate from cocos2d-x. So search ā€œxcode static librariesā€, ā€œandroid studio gradle static librariesā€, ā€œcmake static librariesā€, ā€œwin32 ā€¦ā€, etc. For the most part if you just build the library itself (open the platformā€™s project: cocos2d_libs.xcodeproj, etc), learn how to build static/dynamic library, then create a new project (or use cocos create) and learn how to link with a static/dynamic library separately (you can delete the cocos2d folder copied over as the normal template.

I think this will help you in the long-run if you are a programmer and want to learn build processes for future projects.

2c

2 Likes

Oh, now I understand. Thank you!

Hi,

DId something changed with cocos2d-x-3.15.1 ?
When I run cocos gen-templates on OSX I get:

Python 2.7.10
Error: argument ā€˜gen-templatesā€™ not found.
Try with cocos -h

cocos -v
Python 2.7.10
cocos2d-x-3.15.1
Cocos Console 2.3

cocos -h
Python 2.7.10

/Applications/Cocos/cocos2d-x/tools/cocos2d-console/bin/cocos.py 2.3 - cocos console: A command line tool for Cocos2d-x.

Available commands:
run Compiles, deploy and run project on the target.
gen-libs Generate prebuilt libs of engine. The libs will be placed in ā€˜prebuiltā€™ folder of the engine root path.
luacompile Encrypt and/or compile lua files.
deploy Compile and deploy a project to a device/simulator.
package Manage package for cocos.
compile Compile projects to binary.
gen-simulator Generate Cocos Simulator.
new Creates a new project.
jscompile Compile and/or compress js files.

Available arguments:
-h, --help Show this help information.
-v, --version Show the version of this command tool.
ā€“ol [ā€˜enā€™, ā€˜zhā€™, ā€˜zh_trā€™] Specify the language of output messages.
ā€“agreement [ā€˜yā€™, ā€˜nā€™] Skip the agreement with specified value.

Example:
cocos new --help
cocos run --help

gen-templates was used with Cocos Studio really. There isnā€™t a need for this now.

The instructions here are broken then: http://www.cocos2d-x.org/docs/editors_and_tools/cocosCLTool/index.html#using-the-pre-built-libraries-in-your-projects

And the reference to gen-templates here is wrong too: http://www.cocos2d-x.org/docs/editors_and_tools/cocosCLTool/#unique-command-line-options

Where can I edit that page to reflect the change? The github link on it goes to a 404.

These changes are already fixed in the next docs release.

Could you paste in the new way of doing things from those docs?

When are those docs being released?

We are also talking about this in another thread.

The new docs will come out in a few weeks. I put up beta versions here: slackmoehrle.github.io, although I probably should put up a new beta, this one is weeks old.

Thanks. Yes, these still say you can do things that donā€™t work like:

cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany -t binary

(-t binary is the broken part)

and:

cocos gen-templates

Here:
http://slackmoehrle.github.io/en/editors_and_tools/cocosCLTool.html

Iā€™ll update the build.

1 Like

Did you update the build? I havenā€™t use prebuild library and gen-templates