2013-08-24 24 views
1

我用MinGW的創造,我的Lua版本5.1.4是以下內容是我的步驟:錯誤創建共享庫DLL文件痛飲的Lua示例(Windows 7)中

swig -lua example.i 
gcc -c example_wrap.c -I C:\Lua\5.1\include 
gcc -c example.c -I C:\Lua\5.1\include 
gcc -shared example_wrap.o example.o -o example.dll 

在最後一步的錯誤ocurrs ,這裏是部分錯誤信息

example_wrap.o:example_wrap.c:(.text+0x2aef): undefined reference to `lua_gettop' 
example_wrap.o:example_wrap.c:(.text+0x2afe): undefined reference to `lua_gettop' 
example_wrap.o:example_wrap.c:(.text+0x2b2d): undefined reference to `lua_pushfstring' 
example_wrap.o:example_wrap.c:(.text+0x2b38): undefined reference to `lua_error' 
example_wrap.o:example_wrap.c:(.text+0x2b67): undefined reference to `lua_pushnumber' 
example_wrap.o:example_wrap.c:(.text+0x2ec0): undefined reference to `lua_pushvalue' 
example_wrap.o:example_wrap.c:(.text+0x2ee3): undefined reference to `lua_pushstring' 
example_wrap.o:example_wrap.c:(.text+0x2efe): undefined reference to `lua_pushcclosure' 
example_wrap.o:example_wrap.c:(.text+0x2f11): undefined reference to `lua_rawset' 
example_wrap.o:example_wrap.c:(.text+0x2f24): undefined reference to `lua_pushstring' 
example_wrap.o:example_wrap.c:(.text+0x2f3f): undefined reference to `lua_pushcclosure' 
example_wrap.o:example_wrap.c:(.text+0x2f52): undefined reference to `lua_rawset' 
collect2: ld returned 1 exit status 

看來我沒有包含lua頭文件? 所以我也嘗試這些命令,但沒有使用

gcc -shared example_wrap.o example.o -I C:\Lua\5.1\include -o example.dll 

所以有什麼建議嗎?

+0

嘗試包括'lua51.dll'當你鏈接 – greatwolf

+0

你的意思是?同樣的錯誤。 gcc -shared example_wrap.o -I C:\ Lua \ 5.1 \ lib \ -o example.dll – user2666334

回答

2

嘗試使用此命令鏈接:

gcc -LC:\Lua\5.1\bin -shared example_wrap.o example.o -llua51 -o example.dll 

-LC:\Lua\5.1\bin部分的路徑應該指向你的目錄你lua51.dll(我假定bin,因爲在我的系統,但將其更改爲適合您安裝)。

+0

它的作品,謝謝你,男人。 – user2666334