ubuntu16.04環境下fatal error: lua.h: No such file or directory


1.apt-get install liblua5.1-0-dev

2.編輯hello.c

#include "lua.h"
#include "lauxlib.h"
int main(int argc, char **argv)
{
    lua_State *L = luaL_newstate();
    luaL_openlibs(L);
    luaL_dostring(L, "print('hello, '.._VERSION)");
    return 0;
}

3.gcc -I/usr/include/lua5.1 -o hello hello.c -llua5.1 -lm

4../hello

5.發現報錯

修改hello.c

#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"  

int main(int argc, char **argv)
{
    lua_State *L = luaL_newstate();
    luaL_openlibs(L);
    luaL_dostring(L, "print('hello, '.._VERSION)");
    return 0;
}

 



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM