9

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

Alex
  • 14,973
  • 13
  • 59
  • 94
  • 1
    Are you doing `#include "lua.h"` or `#include `? – Andrey Kamaev Aug 26 '11 at 20:47
  • I am using `#include "lua.h"`. I have also tried `#include "lua/lua.h"` even though that's not what I should need to do. Neither worked. I did not try with `<>`, but if that makes a difference I will be extremely surprised. – Alex Aug 26 '11 at 20:59
  • @Alex Using `#include "lua5.1/lua.h"` worked for me after installing `lua5.1-dev`. – Amir Ali Akbari Mar 13 '15 at 07:17

3 Answers3

16

install lua bin:

sudo apt-get install lua5.1

install lua lib:

sudo apt-get install lua5.1-dev
hustljian
  • 965
  • 12
  • 9
6

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})
Andrey Kamaev
  • 29,582
  • 6
  • 94
  • 88
  • Thanks, I'll try that. Where is the file `FindLua51.cmake` located? I had tried at one point to look it up, but couldn't could find it in a cursory search. Edit: Success! Thank you. – Alex Aug 26 '11 at 21:09
  • 3
    On linux it will be something like `/usr/share/cmake-2.8/Modules/FindLua51.cmake` – Andrey Kamaev Aug 26 '11 at 21:11
1

for Ubuntu 14.04

sudo apt install lua5.2;
sudo apt install liblua5.2-dev;
ipatch
  • 3,933
  • 8
  • 60
  • 99
Honghe.Wu
  • 5,899
  • 6
  • 36
  • 47