Nexuss
Nexuss

Reputation: 67

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?

Upvotes: 3

Views: 1805

Answers (1)

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 compiler command line.)

Upvotes: 4

Related Questions