[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Compiling Lua as a DLL on Windows correctly
- From: David Demelier <demelier.david@...>
- Date: Sun, 20 Apr 2014 10:38:48 +0200
Hi,
I wanted to compile Lua 5.2.3 as a full dynamic library and same for
lua interpreter and lua compiler.
So I compile the library source code (without lua.c and luac.c) with
the LUA_BUILD_AS_DLL to generate lua.lib and lua.dll. This works well.
Then I compile the interpreter and link against the previously
generated lua.lib, works too.
However, the compiler fails to link and says undefined reference to
luaP_opmodes. As a temporarily workaround, I compile the compiler
using whole sources (excluding lua.c) and it seems to work.
But I would like to know what am I doing wrong or if there is an error
for exporting luaP_opmodes for luac.c.
If interested, I have attached the CMakeLists.txt used.
Regards,
--
Demelier David
cmake_minimum_required(VERSION 2.8)
project(Lua)
set(
LIB_SOURCES
src/lapi.c
src/lcode.c
src/lctype.c
src/ldebug.c
src/ldo.c
src/ldump.c
src/lfunc.c
src/lgc.c
src/llex.c
src/lmem.c
src/lobject.c
src/lopcodes.c
src/lparser.c
src/lstate.c
src/lstring.c
src/ltable.c
src/ltm.c
src/lundump.c
src/lvm.c
src/lzio.c
src/lauxlib.c
src/lbaselib.c
src/lbitlib.c
src/lcorolib.c
src/ldblib.c
src/liolib.c
src/lmathlib.c
src/loslib.c
src/lstrlib.c
src/ltablib.c
src/loadlib.c
src/linit.c
)
set(
LUA_SOURCES
src/lua.c
)
set(
LUAC_SOURCES
src/luac.c
)
set(
LUA_INCLUDES
src/lua.h
src/luaconf.h
src/lualib.h
src/lauxlib.h
src/lua.hpp
)
if (WIN32)
add_definitions("/D _CRT_SECURE_NO_WARNINGS")
endif ()
# Lua library
add_library(lualib SHARED ${LIB_SOURCES})
set_target_properties(lualib PROPERTIES OUTPUT_NAME lua)
target_compile_definitions(lualib PRIVATE "LUA_BUILD_AS_DLL")
# Lua executable
add_executable(lua ${LUA_SOURCES})
target_link_libraries(lua lualib)
# Lua compiler
# TODO: Can't compile luac dynamically, fails with luaP_opmodes
add_executable(luac ${LUAC_SOURCES} ${LIB_SOURCES})
# Installation of targets
install(
TARGETS lualib lua luac
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
# Includes
install(
FILES ${LUA_INCLUDES}
DESTINATION include
)