cocos2d-x 3.0rc0版本中 如何使用tolua ,在lua中调用自定义c++类

如题,在2.2的版本中 有tools/tolua++/文件夹下有pkg安装包,然后用tolua++工具 生成 就好了,但在3.0rc0版中 没有找到对应的文件夹及文件,该如何解决呢?

1 Like

You can reffer to README.mdown in tools/tolua folder.

====
Errors in parsing headers:

  1. <severity = Warning,
    location = <SourceLocation file None, line 180, column 9>,
    details = “‘WCHAR_MAX’ macro redefined”>
  2. <severity = Fatal,
    location = <SourceLocation file ‘C:SVN\trunk/cocos/base\CCGeometry.h’, line 30, column 10>,
    details = “‘functional’ file not found”>
    ====

我在编译的时候遇到这个问题,怎么解决,谢谢。

具体可以看这个谢谢。

@samuele3hu
i encounter the same problem.

Errors in parser hearders:
CCGeometry.h line 30,#include

the program can’t find ‘functional’

i look at the file ‘scripting\lua-bindings\auto\lua_cocos2dx_auto.cpp’, it only has these content

#include “lua_cocos2dx_auto.hpp”
#include “cocos2d.h”
#include “SimpleAudioEngine.h”
#include “tolua_fix.h”
#include “LuaBasicConversions.h”

nothing else.

Did you run genbindings.py in windows platform,and can you describe the steps you did?Thank you.

@samuele3hu

  1. i use ‘android-ndk-r9c’
  2. i use python2.7.5
  3. Download pyyaml and install
  4. Download pyCheetah and unzip it to “C:\Python27\Lib\site-packages”
  5. Set environment variables (NDK_ROOT)
  6. in windows cmd console, Go to “cocos2d-x/tools/tolua” folder, and run “python genbindings.py”

then script error.

i did not change any file in cocos and did not add my file, just to test luabinding.

@samuele3hu
my platform is windows8.1

maybe the system has influence

I have encountered a problem

README.mdown in tools/tolua folder said as follows:

My colleague has checked it in window8,it is ok.

@samuele3hu I have met the same problem 2. <severity = Fatal,
location = <SourceLocation file ‘F:\cocos
.h’, line 30, column 10>,
details = “‘functional’ file not found”>

*** Found errors - can not continue
Traceback (most recent call last):
File “F:\cocos2d-x-3.0rc0\tools\bindings-generator/generator.py”, line 1262, i
n
main()
File “F:\cocos2d-x-3.0rc0\tools\bindings-generator/generator.py”, line 1258, i
n main
generator.generate_code()
File “F:\cocos2d-x-3.0rc0\tools\bindings-generator/generator.py”, line 948, in
generate_code
self._parse_headers()
File “F:\cocos2d-x-3.0rc0\tools\bindings-generator/generator.py”, line 984, in
_parse_headers
raise Exception(“Fatal error in parsing headers”)
Exception: Fatal error in parsing headers

Generating lua bindings fails.

@zzccooi I met the same problem,solve it ?

@cloudway,Can you give more information,such as:
platform ,ini config file or other informations.

@zzccooi,Has the error you met already been fixed?what’s the python version did you use?

i had the same problem.why?

Can you paste the detail informations?

i have the same problem, OS X version 10.8.5
X-MacBook-Pro:tolua Y$ python --version
Python 2.7.2

PYTHON_BIN not defined, use current python.
generating userconf.ini…
Generating bindings for cocos2dx…
Using userconfig
[(‘androidndkdir’, ‘/Users/Y/Desktop/dev/NDK/android-ndk-r9d’), (‘clangllvmdir’, ‘/Users/Y/Desktop/dev/NDK/android-ndk-r9d/toolchains/llvm-3.3/prebuilt/darwin-x86_64’), (‘cocosdir’, ‘/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0’), (‘cxxgeneratordir’, ‘/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/tools/bindings-generator’), (‘extra_flags’, ‘’)]

… Generating bindings for target lua

… … Processing section cocos2d-x

====
Errors in parsing headers:

  1. <severity = Fatal,
    location = <SourceLocation file ‘/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/cocos/base/CCGeometry.h’, line 30, column 10>,
    details = “‘functional’ file not found”>
    ====

*** Found errors - can not continue
Traceback (most recent call last):
File “/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/tools/bindings-generator/generator.py”, line 1294, in
main()
File “/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/tools/bindings-generator/generator.py”, line 1290, in main
generator.generate_code()
File “/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/tools/bindings-generator/generator.py”, line 980, in generate_code
self._parse_headers()
File “/Users/Y/Documents/workspace/cocosproject/cocos2d-x-3.0/tools/bindings-generator/generator.py”, line 1016, in _parse_headers
raise Exception(“Fatal error in parsing headers”)
Exception: Fatal error in parsing headers

Generating lua bindings fails.

what is the problem resolve ?please helper