如何将lua5.1添加到CMakeLists.txt文件中?错误:找不到lua.hpp。

我在我的CMakeLists.txt中添加了以下几行:

find_package(Lua51 REQUIRED)

include_directories(${LUA_INCLUDE_DIRS})

target_link_libraries(cmqhd ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${GOBJECT_LIBRARIES} -lntl -lm -lgmp )

但我仍然得到错误:

In file included from /home/kirill/Dropbox/work/dev/cmqhd/source/main.cc:10:0:
/home/kirill/Dropbox/work/dev/cmqhd/source/lua_read.h:9:17: fatal error: lua.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/cmqhd.dir/source/main.cc.o] Error 1
make[1]: *** [CMakeFiles/cmqhd.dir/all] Error 2
make: *** [all] Error 2

文件lua_read.h有以下头文件:

#ifndef LUA_READ_H

#define LUA_READ_H

#include <stdio.h>
#include <string.h>

#include <iostream>
#include <lua.hpp>
...

更新(1)

g++ main.C -I/usr/include/lua5.1/ -llua5.1

已编译。

点赞
用户390066
用户390066

使用 ${LUA_INCLUDE_DIR} 替换 ${LUA_INCLUDE_DIRS}(不是多个文件夹,而是单个文件夹)。

2012-06-03 17:48:26