使用Makefile无法运行简单的嵌入式Lua脚本
2021-12-10 2:17:5
收藏:0
阅读:204
评论:0
我正在尝试设置CMake,以便使用MinGW-w64在Windows 10上与Visual Studio '22配合使用生成Makefile,但是在使用Makefile编译并尝试运行测试应用程序时出现错误。 它打印了embed.c中指定的文本,但没有打印script.lua中的文本。 有没有办法修复这个问题?
我也不理解控制台对此的说法:
In function 'main':
C:/MyLibs/lua-5.1/include/lauxlib.h:112:31: warning: value computed is not used [ -Wunused-value]
112 | (luaL_loadfi1e(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
<squiggle is under the ||>
D: \Programming\Misc_Lua\embed\embed.c:18:5: note: in expansion of macro 'luaL_dofile'
18 | luaL_dofile(L, "script.lua");
<squiggle is under the luaL_dofile>
这是script.lua:
-- script.lua
print("Hello, World from File")
这是embed.c:
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "EmbedConfig.h"
int main(int argc, char ** argv) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
//open a Lua file:
printf("This line in directly from C\n\n");
luaL_dofile(L, "script.lua");
printf("\nBack to C again\n\n");
lua_close(L);
return 0;
}
这是CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
# set the project name and version
project(Embed VERSION 1.0)
find_package(Lua51 REQUIRED)
# configure a header file to pass the version number only
configure_file(EmbedConfig.h.in EmbedConfig.h)
# add the executable
add_executable(Embed embed.c)
# add the binary tree to the search path for include files
# so that we will find EmbedConfig.h
target_link_libraries(Embed "${LUA_LIBRARIES}")
target_include_directories(Embed PUBLIC "${PROJECT_BINARY_DIR}" "${LUA_INCLUDE_DIR}")
# add the install targets
install(TARGETS Embed DESTINATION bin)
install(FILES "${PROJECT_BINARY_DIR}/EmbedConfig.h"
DESTINATION include
)
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${Embed_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${Embed_VERSION_MINOR}")
include(CPack)
原文链接 https://stackoverflow.com/questions/70298996
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
- 如何编写 Lua 模式将字符串(嵌套数组)转换为真正的数组?