Compiling Lua 5.2 alpha under VS2010

拜拜、爱过 提交于 2020-01-02 05:45:14

问题


I'd like to compile Lua 5.2 alpha under visual studio but I'm getting errors and I have no clue how to fix them.

error LNK1169: one or more multiply defined symbols found
error LNK2005: _main already defined in lua.obj

I'd be grateful if anyone could guide me through the creation of a VS2010 solution for Lua 5.2 alpha, or point me to related resources.

Thanks in advance.


回答1:


You are most probably compiling both luac.c and lua.c in one VS project. To build Lua yourself in VS you need three projects:

library - this should be either DLL or static library project. Should include every .c file under src/ except luac.c and lua.c. You only need this if you are embedding.

compiler - console executable, containing luac.c

interpreter - console executable, containing lua.c




回答2:


Sounds like you included lua.c, or luac.c, with another program. Each of these is a separate program with their own main. You need to include just one of them to build the standalone Lua component, or neither if you're embedding Lua in your own application.




回答3:


The Lua source distribution includes a console interpreter, which already defines main, and you don't want that. Just look in the Lua source and delete or comment out the mains that you find.



来源:https://stackoverflow.com/questions/6321927/compiling-lua-5-2-alpha-under-vs2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!