簡體   English   中英

我正在嘗試編寫一個簡單的Lua腳本,並且time函數給了我一個“正在加載模塊”錯誤

[英]I'm trying to write a simple Lua script, and the time function is giving me a “loading module” error

我正在嘗試學習Lua,而我正在學習的教程將以下代碼作為步驟:

 print("Welcome to")
 print("THE GAME")

我擁有一些編程經驗,因此決定進一步:

 require "socket"

 function sleep(sec)
     socket.select(nil, nil, sec)
 end

 print("Welcome to.....")
 sleep(1.25)
 print("...")
 sleep(1.25)
 print("...")
 sleep(1.25)
 print("...")
 sleep(1.25)
 print("...")
 sleep(1.25)
 print("THE GAME")

由於某種原因,這個小的添加立即給我一個錯誤:

  dave@dave-[my laptop]:~/Code/Lua/Test$ lua main.lua
  lua: error loading module 'socket.core' from file '/home/dave/torch/install/lib/lua/5.1/socket/core.so':
     /home/dave/torch/install/lib/lua/5.1/socket/core.so: undefined symbol: lua_pcall
  stack traceback:
     [C]: in ?
     [C]: in function 'require'
     /home/dave/torch/install/share/lua/5.1/socket.lua:12: in main chunk
     [C]: in function 'require'
     main.lua:1: in main chunk
     [C]: in ?

我不知道我怎么打破了這么簡單的東西。 我安裝Lua錯了嗎? 我在Ubuntu 14.04上運行Lua 5.2.3。

lib/lua/5.1/socket/core.so

我正在運行Lua 5.2.3

好吧,那是你的問題。 Lua與先前的“次要”版本不二進制兼容。 因此,當您在Lua 5.2中執行時,無法加載為Lua 5.1構建的.so。

假設套接字庫的版本為5.2,則需要對其進行升級。 如果不能這樣做,則需要降級到Lua 5.1。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM