windows(Vista)下,用mingw编译运行swig2.0.4下Examples\lua\simple的内容
准备工作,把lua源代码的头文件拷贝到include目录;lua51.dll拷贝到lib目录
一方面,首先默认是用直接lua运行的步骤如下:
>swig -lua example.i
>gcc -c example.c
>gcc -c -Iinclude example_wrap.c
>gcc -shared -Iinclude -Llib -llua51 example.o example_wrap.o -o example
.dll
>lua5.1 runme.lua
The gcd of 42 and 105 is 21
Foo = 3
Foo = 3.1415926
运行成功。
另一方面,其次是用C运行。
利用文档(http://www.swig.org/Doc2.0/Lua.html#Lua)创建min.c文件
把runme.lua文件开头的require部分去掉,另存为runme2.lua
其余的步骤如下:
>gcc -c -Iinclude min.c
>gcc -Llib -llua51 min.o example.o example_wrap.o -o example.e
xe
>example runme2.lua
The gcd of 42 and 105 is 21
Foo = 3
Foo = 3.1415926
运行又成功
转载于:https://blog.51cto.com/harvey/752097