Friday, 16 December 2011

Gyp and libuv

One open source project that I've heard a bit about recently is libuv.  A cross-platform asynchronous IO library, it is something that I can plug into Kristjan Valur's stacklesslib module.  And all the work writing the Python bindings has already been done by Saúl Ibarra Corretgé in his pyuv project.

Anyway, I spent some time today getting it compiling for Windows and thought I would post a note about gyp, so that I could remember to avoid the same problems in future.  Gyp is a pretty handy build system. Just define the gist of what needs to be compiled in a mildly arcane mark-up, and it will churn out Makefiles, Visual Studio projects and solutions and a range of other things.  However, as with most programming related things, it is the little details that trip you up and cause you to waste your time.

Missing include files

If you are compiling with Visual Studio 2008, and it includes inttypes.h or stdint.h, errors will occur as these files will not be present.

libuv\include\uv.h(54): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
Apparently the solution to this, after a lot of googling on what constitutes a wi-fi connection over here in New Zealand,  is to download something like the custom msinttypes versions of these files.   And then bung them somewhere Visual Studio will find it.. wherever that is.

Overriding gyp settings

If you are compiling a static library with Visual Studio using gyp, it will start with a range of default settings.  You will not be able to override these settings no matter where you put your own custom versions in your gyp configuration file.  The specific problem I had was that Python extensions are compiled with a RuntimeLibrary setting of MultiThreadedDLL and libuv is compiled with a different setting of MultiThreaded.  These are of course incompatible, and a variety of compilation errors are caused by it.
LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR90.dll)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
build\lib.win32-2.7\pyuv.pyd : fatal error LNK1120: 1 unresolved externals
In order to force this gyp setting to change from the default, it needs to be defined within a conditional expression.  The default setting is also a conditional expression, and .. well.. work it out.  Maybe it's in the documentation somewhere, but not in a clearly stated way that I could find.

Thursday, 15 December 2011

Xi'an - Beiyuanmen - Quesadillas

This stall on Beiyuanmen (北院门) always had a queue no matter what time I went past. First thing in the morning, the afternoon or even late at night.

2011-11-19 - Xian - Quesadillas - 00 - Stall

You basically choose a filling, or combination. Beef and lamb are both options, as well as a variety of generic looking rabbit foods. Meat is more expensive, of course. I think it was maybe 7 RMB for the one without meat, and 10 RMB for one with. Lady one takes the money, constructs the uncooked "quesadillas" and also on receiving the cooked ones slices and hands out the finished product to the customer.

2011-11-19 - Xian - Quesadillas - 03 - Lifting

Lady two fries them and bungs them over to lady one.

2011-11-19 - Xian - Quesadillas - 01 - Frying

Then you get a bag with four quarters which look something like this.

2011-11-19 - Xian - Quesadillas - 05 - Innards

Extra extra spice was added on request to mine, but I think you'd be better off adding some rabbit food to get more flavour.  This was nicely, and not overly spicy.

Monday, 12 December 2011

Xi'an - City Wall

The tourist attraction in Xi'an that appealed to me the most, was the city wall. A wide walkable area presumably with a good view, which you could circle around the center of town. It sounded ideal for a morning run, but unfortunately turned out to be unsuitable for that. On one hand, it opened too late and cost 40 RMB per entrance, and on the other, the stones were often slippery and that was on a good day with blue skies. Oh well, it was still an enjoyable presumably 7 km long walk.

You can rent bicycles, but I chose not to. In order to rent one, you need to either leave your passport as a deposit, or 500 RMB. As I planned to go halfway around and depart out the other side where my hotel was, it wasn't really convenient for me to come back to my starting point on the opposite side from my destination, in order to return the bike.

The first few days I was in Xi'an, the weather was cold and grey and thankfully I didn't get time to go to the wall. Luckily the day I did decide to go, was the first blue sky and relatively not cold day there during my stay.

Cross the carpeted bridges over the moat, pass the guards, and in you go.

2011-11-18 - Xian - City wall - 01 - South entrance

The young bird in the smock is there to check the tickets. Or rather tell people who didn't realise that the building off to the side tens of meters back (or maybe a kilometer back if you made this mistake at the terracotta warriors) sells tickets that you need to go back and buy one there.

2011-11-18 - Xian - City wall - 02 - Right guard

The costume looked kind of fake and costumish to me, but maybe it was genuine.

2011-11-18 - Xian - City wall - 03 - Left guard

Back at the ticket office, the ticket lady had toddled off somewhere completely unbeknownst to this older man who kept telling me to buy one from her (in Mandarin). Several people and myself loitered around waiting for five minutes for her to return, some of whom in the meantime had made it up to the young bird at the gate to find out they needed to come back here to buy the actual ticket.

2011-11-18 - Xian - City wall - 04 - Ticket office

Nice moat.

2011-11-18 - Xian - City wall - 05 - Moat

Looking through the southern gateway. This is actually the nicest entrance, and the fanciest. In order to get here, you need to cross a wide and very busy street though. It's just as well that Chinese drivers are in my experience extremely happy to let pedestrians cross and have no problem slowing or stopping. If you tried to cross this way in the states, you'd probably get hit and run, then some cop would come along and give you a jaywalking ticket. Here, no-one is ever going to make it to this entrance or for that matter the less fancy but similarly inaccessible northern one, unless this type of street crossing is sanctioned.

2011-11-18 - Xian - City wall - 06 - Entrance courtyard - Inwards

If I ever revisit this, maybe I'll read this sign. To be honest, no point in reading something you are not going to remember.

2011-11-18 - Xian - City wall - 07 - Entrance courtyard - Sign

The staircase to the gatehouse, whose walkable area at the top is not connected to the actual city wall, was steep but not the steepest I've come across in China.

2011-11-18 - Xian - City wall - 08 - Gatehouse wall - Staircase

Looking out over the gatehouse wall at the entrance area.

2011-11-18 - Xian - City wall - 09 - Gatehouse wall - Entrance view

More signs what I didn't read.

2011-11-18 - Xian - City wall - 10 - Gatehouse wall - Sign

2011-11-18 - Xian - City wall - 11 - Entrance courtyard - Sign 2

This is looking down from the gatehouse into the southern entrance courtyard.

2011-11-18 - Xian - City wall - 12 - Ring wall - Entrance courtyard view

And from the gatehouse out into the southern direction over the city. Bit of a smog going on there, but blue skies.

2011-11-18 - Xian - City wall - 13 - Ring wall - Gatehouse view

The gatehouse bell. Used for something probably written on one of those signs.

2011-11-18 - Xian - City wall - 14 - Ring wall - Bell

Looking out along the westward side of the southern length of the wall.

2011-11-18 - Xian - City wall - 15 - Ring wall - Westward

Looking into the city inside the southern gate entrance.

2011-11-18 - Xian - City wall - 16 - Ring wall - South gate inward

You can rent bicycles, or you can rent these cart things. I think they were a little more expensive, but don't remember how much.

2011-11-18 - Xian - City wall - 17 - Ring wall - Rentable bike cart

There are a decent number of smaller staircases down into the city, with closed and locked gates blocking access to prevent people from gaining unpaid access.

2011-11-18 - Xian - City wall - 18 - Ring wall - Closed Wumu gate

This sign describes that this particular gate was added when there was a threat of the Japanese attacking.
2011-11-18 - Xian - City wall - 19 - Ring wall - Wumu gate sign

One of the rentable bicycles, seems to work..

2011-11-18 - Xian - City wall - 20 - Ring wall - Rentable bicycle

Piles of random garbage being cleaned up on the street down below.

2011-11-18 - Xian - City wall - 21 - Ring wall - Street cleaner

The outside of the city wall almost the entire way around the half I walked, seemed to be covered with park and public Chinese-style exercise machines. In this case, someone was flying a kite.

2011-11-18 - Xian - City wall - 22 - Ring wall - Outer park

A less kite-centric view of it.

2011-11-18 - Xian - City wall - 23 - Ring wall - Outer park

A more interesting looking section of moat. If only the water was clean and had fish so that there was a point to getting down there. But if people were fishing out of there, it wouldn't be the dirtiest water I'd seen people fish from in China. Hopefully they're doing it for the sport, not the eating.

2011-11-18 - Xian - City wall - 24 - Ring wall - Outer moat section

More cyclists. There were groups of up to 15 people cycling around together.

2011-11-18 - Xian - City wall - 25 - Ring wall - Cyclists

Some kid with a motorcycle, which he seemed to be enjoying.

2011-11-18 - Xian - City wall - 26 - Ring wall - Kiddy motorbike

The southwest corner.

2011-11-18 - Xian - City wall - 27 - Ring wall - Southwest corner

A sign going into detail about all the interesting things that make a southwest corner interesting.

2011-11-18 - Xian - City wall - 28 - Ring wall - Southwest corner sign

Looking down the northward stretch of the west wall.

2011-11-18 - Xian - City wall - 29 - Ring wall - Northward

And back eastward.

2011-11-18 - Xian - City wall - 30 - Ring wall - Back eastward

Besides the spitting, hygiene-wise one of the worst things about China is the trough toilets. I decided to take a few photos of this one, just to capture the experience as there was no-one around. The outside entrance in this case, was freshly cleaned and had a curtain of flies.

2011-11-18 - Xian - City wall - 31 - Ring wall - Eastern toilet men's door

This trough is not unflushed and is clean and unsoiled. Not very common.

2011-11-18 - Xian - City wall - 32 - Ring wall - Eastern toilet men's trough

Heading to the northwest corner, there's a monastery. I particularly liked that they had cell phone tower with fake tree branches and leaves.

2011-11-18 - Xian - City wall - 33 - Ring wall - Northeast monastery

Some inner levels to the wall, to what end, I do not know.

2011-11-18 - Xian - City wall - 34 - Ring wall - Eastward inner levels

And the eastward view from the northwest corner.

2011-11-18 - Xian - City wall - 35 - Ring wall - Eastward

At the northern gate, in the center of the northern wall, there's another bell.

2011-11-18 - Xian - City wall - 36 - Ring wall - Northern bell

Looking in to the northern part of the city inside the wall.

2011-11-18 - Xian - City wall - 37 - Ring wall - Northern outer intersection

And back westward down the moat.

2011-11-18 - Xian - City wall - 38 - Ring wall - Northern westward moat

And finally to the northern part of the city outside the wall.

2011-11-18 - Xian - City wall - 39 - Ring wall - Norther outer hotel view

Uncrowded and a reasonably nice day, this was one of the better attractions I experienced in Xi'an.