简体   繁体   English

lua_pcall去了哪里? (OSX Lion上的Lua 5.2.0)

[英]Where did lua_pcall go? (Lua 5.2.0 on OSX Lion)

Problem: 问题:

$ clang++ -L../lib/osx/ -I../include/ -o test Script.cpp Main.cpp Verbose.cpp -llua -lUnitTest++
Undefined symbols for architecture x86_64:
  "_lua_pcall", referenced from:
      LuaSystem::dostring(char const*) in Script-EgY0dM.o
     (maybe you meant: _lua_pcallk)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Let's look at my lua build: 让我们看看我的lua构建:

$ cd src/
stevenlu443@steven-mba(Jun 09 02:41:58)[~/Downloads/lua-5.2.0/src]
$ ls
Makefile   lcorolib.c ldump.o    llex.o     lopcodes.o ltable.c   luac.c
lapi.c     lcorolib.o lfunc.c    llimits.h  loslib.c   ltable.h   luac.o
lapi.h     lctype.c   lfunc.h    lmathlib.c loslib.o   ltable.o   luaconf.h
lapi.o     lctype.h   lfunc.o    lmathlib.o lparser.c  ltablib.c  lualib.h
lauxlib.c  lctype.o   lgc.c      lmem.c     lparser.h  ltablib.o  lundump.c
lauxlib.h  ldblib.c   lgc.h      lmem.h     lparser.o  ltm.c      lundump.h
lauxlib.o  ldblib.o   lgc.o      lmem.o     lstate.c   ltm.h      lundump.o
lbaselib.c ldebug.c   liblua.a   loadlib.c  lstate.h   ltm.o      lvm.c
lbaselib.o ldebug.h   linit.c    loadlib.o  lstate.o   lua        lvm.h
lbitlib.c  ldebug.o   linit.o    lobject.c  lstring.c  lua.c      lvm.o
lbitlib.o  ldo.c      liolib.c   lobject.h  lstring.h  lua.h      lzio.c
lcode.c    ldo.h      liolib.o   lobject.o  lstring.o  lua.hpp    lzio.h
lcode.h    ldo.o      llex.c     lopcodes.c lstrlib.c  lua.o      lzio.o
lcode.o    ldump.c    llex.h     lopcodes.h lstrlib.o  luac
stevenlu443@steven-mba(Jun 09 02:41:59)[~/Downloads/lua-5.2.0/src]
$ nm liblua.a | grep _lua_pcall
115:0000000000001a30 T _lua_pcallk
116:0000000000003b40 S _lua_pcallk.eh
1563:                 U _lua_pcallk
1839:                 U _lua_pcallk
stevenlu443@steven-mba(Jun 09 02:42:12)[~/Downloads/lua-5.2.0/src]
$ nm *.o | grep _lua_pcall
115:0000000000001a30 T _lua_pcallk
116:0000000000003b40 S _lua_pcallk.eh
597:                 U _lua_pcallk
977:                 U _lua_pcallk
2630:                 U _lua_pcallk
2760:                 U _lua_pcallk

Why does _lua_pcall not exist? 为什么_lua_pcall不存在? The 5.2 doc seems to say pcallk does the same as pcall but has the benefit of being able to yield but pcall should still be available... 5.2 doc似乎说pcallk与pcall一样,但是具有能够屈服的优点,但pcall应该仍然可用。

UPDATE: I just realized I am trying to link to 5.2 using older (5.1?) headers... Does anybody know where there is a list that says which headers are necessary? 更新:我刚刚意识到我正在尝试使用旧的(5.1?)标头链接到5.2。有人知道哪里有一个列表,其中列出了哪些标头是必需的吗? I don't need all the headers from the Lua source. 我不需要Lua源中的所有标头。

We can infer from what we've seen here that in 5.2 pcall is implemented using _lua_pcallk . 从这里我们可以看到,在5.2中,pcall是使用_lua_pcallk实现的。

To compile programs that use the Lua C API, you need to include lua.h and frequently also lauxlib.h and sometimes lualib.h . 要编译使用Lua C API的程序,您需要包括lua.h ,经常还包括lauxlib.h ,有时还包括lualib.h

When you change the version of Lua, say from 5.1 to 5.2, you need to recompile your program. 当您将Lua的版本从5.1更改为5.2时,您需要重新编译程序。 When you change releases of the same version, say from 5.1.4 to 5.1.5, you don't need to recompile, just relink. 当您将同一版本的发行版从5.1.4更改为5.1.5时,无需重新编译,只需重新链接即可。

Of course, in all cases, make sure you use consistent headers and libraries, that is, do not mix headers and libraries from different versions or releases. 当然,在所有情况下,请确保使用一致的头和库,即,不要混用来自不同版本或发行版的头和库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM