我试图使用ctypes和ctypeslib将C头转换为Python库。我在OSX 10.6.4(雪豹)上运行Python2.7。
我要转换的头文件是mcbcio32.h,位于/header/mcbcio32.h中
我希望在同一个文件夹中创建一个xml输出,名为mcbcio32.xml。在
我跑h2xml.py文件使用以下命令从ctypeslib文件夹将c头转换为包装的xml文件:
$python h2xml.py文件/header/mcbcio32.h-o mcbcio32.xml-q-c
输出:
Traceback (most recent call last):
File "h2xml.py", line 92, in <module>
sys.exit(main())
File "h2xml.py", line 86, in main
compile_to_xml(argv)
File "h2xml.py", line 79, in compile_to_xml
parser.parse(files)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypeslib/codegen/cparser.py", line 306, in parse
self.create_final_xml(include_files, types, None)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypeslib/codegen/cparser.py", line 265, in create_final_xml
self.create_xml(source, xmlfile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypeslib/codegen/cparser.py", line 97, in create_xml
stdin=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1201, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
我能从三个剧本中看出什么叫h2xml.py文件, cparser.py,最后子流程.py. 所有这些脚本都是由Python开发人员编写的,因此我猜测错误就在我如何运行发出命令的地方。在
氢气xml.py文件代码:
^{pr2}$我已经安装了GCC-XML,并将ctypeslib粘贴到: /库/框架/Python.framework/Versions/2.7/lib/Python2.7/ (我的本地Python库路径)
如果有其他有用的信息,请告诉我。提前谢谢你的帮助。在
问题在于gccxml的安装。确保在安装gcc xml时也安装cmake函数(cmake.org网站). 在gcc安装文件夹上正确使用cmake解决了我遇到的所有目录问题。在
相关问题 更多 >
编程相关推荐