如何将lua5.1添加到CMakeLists.txt?错误:未找到 lua.hpp

How to add lua5.1 to CMakeLists.txt? error: lua.hpp is not found

本文关键字:错误 hpp lua CMakeLists lua5 添加 txt      更新时间:2023-10-16

我在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               

编译

${LUA_INCLUDE_DIR} 而不是 ${LUA_INCLUDE_DIRS} (dir, not dirS)