libRocket Python & Visual Studio 2010

Discussion about using Python with libRocket.

libRocket Python & Visual Studio 2010

Postby Ologon on Sun Aug 07, 2011 7:32 pm

Hi!

I've recently decided to use python with librocket since I found the script embedding very cool and much intuitive for capturing events and GUI scripting.

Although I've successfully compiled rocket with VS 2010 and it is working perfectly, I'm having troubles with python.

I'm following the guide here: http://librocket.com/wiki/documentation ... oostPython
and I downloaded the latest sources of python. Unfortunately the solution provided doesn't convert correctly in vs 2010 and I can't compile it..

Has anyone got it working with vs 2010?

Any help is truly appreciated :)
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy

Re: libRocket Python & Visual Studio 2010

Postby lloydw on Mon Aug 08, 2011 6:36 am

What goes wrong with the conversion?

You could try generate a VS2010 project with CMake.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: libRocket Python & Visual Studio 2010

Postby Ologon on Mon Aug 08, 2011 10:59 am

Hi, thanks for your reply.

VS 2010 just says there were errors during conversion and all solution projects are then marked as "unavailable".
I saw this issue reported here too: http://bugs.python.org/issue12267
And it looks the problem is related with vs x64 support, and python doesn't officially support vs 2010.

However that user posted a patch and I think i will give it a try.

I hope it works.. Downgrading the whole project to VS 2008 might be a bit time consuming :|
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy

Re: libRocket Python & Visual Studio 2010

Postby Ologon on Mon Aug 08, 2011 10:03 pm

EDIT: Compiling RocketPython is really much harder than I thought :|
I've done tests with both vs 2010 and vs 2008 but both give the same errors: After correctly compiling python 2.7 and boost.python, and setting up Cmake (I had to remove "LIBRARY" from line 151 in cmakelist.txt to get it working) for librocket I was able to compile RocketCore, RocketDebugger, RocketControls, but _rocket_core and _rocket_controls won't compile giving me these kind of errors:

Code: Select all
error LNK2001: unresolved external symbol __Py_NoneStruct


and other python symbols which are found in the python27.lib. Downloading the librocket SDK for vs 2008 and compiling pyinvaders gave me exactly the same error, even if I'm correctly linking to python27.lib and boost.
Using "dumpbin" on python27.lib reveals that the symbol _Py_NoneStruct is there and I really can't understand why the compiler complains about it.

Using vs 2010 lead to the same result.. I really wonder what I'm doing wrong? :(

The only reason I can think of is an imcompatibility with python 2.7, so i was thinking to try with python 2.5 instead.

Any help is appreciated :)
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy

Re: libRocket Python & Visual Studio 2010

Postby lloydw on Tue Aug 09, 2011 10:11 pm

That seems very odd, I know getting the Python stuff to build is a bit troublesome.

Are you building everything as static or dynamic files?
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: libRocket Python & Visual Studio 2010

Postby Ologon on Wed Aug 10, 2011 1:13 pm

I think I finally did it! :D

I'm compiling everything as dynamic with /MD and /MDd. I think the problem was that I was using the wrong pyconfig.h. The right one was located in python/PC.

I've not tested it yet, but at least librocket-python 2.7 compiles just fine with vs 2010 :)
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy

Re: libRocket Python & Visual Studio 2010

Postby Ologon on Wed Aug 10, 2011 3:56 pm

This is frustrating :(

I successfully compiled pyinvaders and when I launch it python correctly imports rocket.py, however it is unable to load _rocketcore.pyd:

Code: Select all
ImportError: DLL load failed: The specified module could not be found.


EDIT: Okay, I think I'm getting close to the solution. _rocketcore imports but only with python in release mode. (I noticed python_d.exe is unable to load any kind of .pyd). So the solution would be to use release python even in debug mode (Which wouldn't be a problem I think, since we're not debugging python) but no matter what I try, pyinvaders seems to link to python_d.dll in debug mode
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy

Re: libRocket Python & Visual Studio 2010

Postby lloydw on Wed Aug 10, 2011 11:34 pm

Yes, by default Boost::Python will build against release Python even in debug mode.

I prefer to use Debug Python so forced my build on Boost::Python to use debug Python when I built it and include Python.h before including Boost::Python, which forces it to use debug.

If you want to use the release version of Python, you should just be able to comment out line 35 (#include <Python.h>) from Core/Python/Python.h as boost will then include it in release mode if I remember correctly (its been a long time! :)
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: libRocket Python & Visual Studio 2010

Postby Ologon on Thu Aug 11, 2011 2:03 pm

Thanks! That worked :)

I'm now finally importing my all time favourite scripting language into my project and see if it works correctly :D
Ologon
 
Posts: 10
Joined: Thu Jul 28, 2011 2:55 pm
Location: Italy


Return to libRocket and Python


cron