简体   繁体   中英

How do I get the lua libraries for linux so that I can use them in C?

I am following this tutorial https://lucasklassmann.com/blog/2019-02-02-how-to-embeddeding-lua-in-c/#installation and I was wondering how I could get the following libraries installed on ubuntu:

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

I tried installing all sorts of lua-related things, like:

sudo apt-get install liblua5.1-0-dev
sudo apt-get install lua-devel

But I still could not get things to work. Does anyone know how to get lua working for C?

The Ubuntu packages for Lua add an extra subdirectory so that you can have multiple versions installed at once. Either do this instead:

#include <lua5.1/lua.h>
#include <lua5.1/lualib.h>
#include <lua5.1/lauxlib.h>

Or pass -I/usr/include/lua5.1 on the compiler command line. (If you get undefined references errors after either of these options, then you probably need to append -llua5.1 to the complier command line.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM