cxx2rs icon indicating copy to clipboard operation
cxx2rs copied to clipboard

Convert jvmti header files

Open ghost opened this issue 10 years ago • 13 comments
trafficstars

Hi, I want to convert JVM Tool Interface header files (jdk1.7.0_79\include). There is no any lib file, just headers.

python.exe cxx2rs C:\Users...\src\jvmti.h > jvmti.rs Traceback (most recent call last): File "C:\Python27\lib\runpy.py", line 162, in run_module_as_main "main", fname, loader, pkg_name) File "C:\Python27\lib\runpy.py", line 72, in run_code exec code in run_globals File "C:\Python27\Lib\site-packages\cxx2rs__main.py", line 13, in from parser import canonical_function_name ImportError: cannot import name canonical_function_name

How do I do that? thanks

ghost avatar Aug 20 '15 16:08 ghost

That path looks pretty incorrect:

C:\Python27\Lib\site-packages\cxx2rs__main_.py

Is that really what the output looks like? It should be something like

C:\Python27\Lib\site-packages\cxx2rs\__main_.py

(Please note the added backslash)

manuels avatar Aug 20 '15 16:08 manuels

I tried to run a script in your way

but error still occurs

python.exe C:\Python27\Lib\site-packages\cxx2rs__main__.py C:\Users...\src\jvm.h > jvmti.rs Traceback (most recent call last): File "C:\Python27\Lib\site-packages\cxx2rs__main__.py", line 13, in from parser import canonical_function_name ImportError: cannot import name canonical_function_name

ghost avatar Aug 20 '15 17:08 ghost

The thing is that all files should be located in the directory C:\Python27\Lib\site-packages\cxx2rs\. In this folder there should be (among other files) the files __main__.py and parser.py. Could you check if this is the case?

manuels avatar Aug 20 '15 17:08 manuels

I've installed script by pip, so all files are presented image

ghost avatar Aug 20 '15 17:08 ghost

That's really weird. Could you check if parser.py contains in line 95:

def canonical_function_name(node):

If so, please cd C:\Python27\Lib\site-packages\cxx2rs and run

python.exe C:\Python27\Lib\site-packages\cxx2rs\__main__.py C:\Users...\src\jvm.h > jvmti.rs

from there.

manuels avatar Aug 20 '15 17:08 manuels

Yes, there is canonical_function_name function at line 95

C:\Python27> python.exe C:\Python27\Lib\site-packages\cxx2rs__main__.py C:\Program Files\Java\jdk1.7.0_79\include\jvmti.h > jvmti.rs Traceback (most recent call last): File "C:\Python27\Lib\site-packages\cxx2rs__main__.py", line 13, in from parser import canonical_function_name ImportError: cannot import name canonical_function_name

ghost avatar Aug 20 '15 18:08 ghost

please change the current directory before calling python.exe^^:

cd C:\Python27\Lib\site-packages\cxx2rs

manuels avatar Aug 20 '15 18:08 manuels

C:\Python27\Lib\site-packages\cxx2rs> C:\Python27\python.exe C:\Python27\Lib\site-packages\cxx2rs__main__.py "C:\Program Files\Java\jdk1.7.0_79\include\jvmti.h" > jvmti.rs Traceback (most recent call last): File "C:\Python27\Lib\site-packages\cxx2rs__main__.py", line 13, in from parser import canonical_function_name ImportError: cannot import name canonical_function_name

ghost avatar Aug 20 '15 18:08 ghost

could you try to change line 13 in __main__ to

 from .parser import canonical_function_name

or also try

 from cxx2rs.parser import canonical_function_name

manuels avatar Aug 20 '15 19:08 manuels

(Windows is weird ;)

manuels avatar Aug 20 '15 19:08 manuels

Can this problem be caused by python path is not set to PATH env. variable?

ghost avatar Aug 20 '15 19:08 ghost

With this 'from cxx2rs.parser import canonical_function_name' I also have a error (clang is installed to 'C:\Python27\Lib\site-packages\clang')

Traceback (most recent call last): File "C:\Python27\Lib\site-packages\cxx2rs__main__.py", line 88, in main() File "C:\Python27\Lib\site-packages\cxx2rs__main__.py", line 34, in main index = clang.cindex.Index.create() File "C:\Python27\lib\site-packages\clang\cindex.py", line 2119, in create return Index(conf.lib.clang_createIndex(excludeDecls, 0)) File "C:\Python27\lib\site-packages\clang\cindex.py", line 141, in get value = self.wrapped(instance) File "C:\Python27\lib\site-packages\clang\cindex.py", line 3429, in lib lib = self.get_cindex_library() File "C:\Python27\lib\site-packages\clang\cindex.py", line 3460, in get_cindex_library raise LibclangError(msg) clang.cindex.LibclangError: [Error 126] The specified module could not be found. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

ghost avatar Aug 20 '15 19:08 ghost

This is at least one step further! ;) On linux I would set LD_LIBRARY_PATH to /usr/lib/llvm-3.5/lib. No clue how to do this on Windows.

manuels avatar Aug 20 '15 19:08 manuels