Unable to find Lua headers with find_package in cmake

眉间皱痕 提交于 2021-01-27 03:54:13

问题


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.)


回答1:


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})



回答2:


install lua bin:

sudo apt-get install lua5.1

install lua lib:

sudo apt-get install lua5.1-dev



回答3:


for Ubuntu 14.04 sudo apt-get install lua5.2 sudo apt-get install liblua5.2-dev



来源:https://stackoverflow.com/questions/7210154/unable-to-find-lua-headers-with-find-package-in-cmake

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