无法在cmake中使用find_package找到Lua标头

发布于 2024-12-01 18:46:09 字数 602 浏览 0 评论 0原文

我正在尝试使用 CMake 为我使用 Lua 的项目构建生成 make 文件。当我运行 make 时,出现此错误:

/path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory

在 CMakeLists.txt 文件中,我有以下几行,我认为可以做到这一点,但显然它们还不够:

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})

Lua51_Include_Dirs 似乎是空的(尝试通过消息运行它)命令不打印任何内容)所以我怀疑它只是找不到它。我需要指定在哪里寻找Lua吗?我的印象是 find_package 的全部要点是它会在一组预定义的位置中查找,这样我就不需要指定它的具体位置。

(这是在 Ubuntu 机器上,我确实安装了 Lua 软件包。)

I'm trying to use CMake to build generate the make file for a project of mine that uses Lua. When I run make I get this error:

/path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory

In the CMakeLists.txt file, I have the following lines, which I thought would do it, but apparently they're not enough:

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})

Lua51_Include_Dirs appears to be empty (attempting to run it though the message command doesn't print anything) so I suspect that it just can't find it. Do I need to specify where to look for Lua? I was under the impression that the whole point of find_package was that it would look in a set a predefined places so that I don't need to specify where it is specifically.

(This is on an Ubuntu machine and I do have the Lua packages installed.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

善良天后 2024-12-08 18:46:09

安装lua bin:

sudo apt-get install lua5.1

安装lua lib:

sudo apt-get install lua5.1-dev

install lua bin:

sudo apt-get install lua5.1

install lua lib:

sudo apt-get install lua5.1-dev
笛声青案梦长安 2024-12-08 18:46:09

从 cmake 2.8 探索 FindLua51.cmake 我发现它设置了 LUA_INCLUDE_DIR 变量而不是 Lua51_INCLUDE_DIRS。所以cmake代码应该是

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${LUA_INCLUDE_DIR} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})

Exploring FindLua51.cmake from cmake 2.8 I found that it sets LUA_INCLUDE_DIR variable instead of Lua51_INCLUDE_DIRS. So cmake code should be

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${LUA_INCLUDE_DIR} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})
↙厌世 2024-12-08 18:46:09

适用于 Ubuntu 14.04

sudo apt install lua5.2;
sudo apt install liblua5.2-dev;

for Ubuntu 14.04

sudo apt install lua5.2;
sudo apt install liblua5.2-dev;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文