I know that replying to your own thread is not the done thing, especially this long after the thread went cold. But I have to say this...
"When you want to write an extension to Lua in C write a rockspec and let luarocks handle building the extension"
Makes it portable too :)