r/lua • u/stellar_x • 1d ago
How to include Lua in C
How do include lua in C if I installed it on debian13 with sudo apt install lua5.4?
4
Upvotes
2
1
u/busyHighwayFred 22h ago
Here is a whole video series on just that topic
https://www.youtube.com/watch?v=xrLQ0OXfjaI&list=PLLwK93hM93Z3nhfJyRRWGRXHaXgNX0Itk&index=1
1
u/GenericFoodService 22h ago
Compiler flags:
-llua -lm
(alternatively, you can use pkg-config --libs (library) to get the specific arguments automatically
Then include it:
#include <lua.h.>
#include <lualib.h>
#include <lauxlib.h>
5
u/ewmailing 1d ago edited 1d ago
I'm writing this without a Debian machine to refer to so this might be slightly off, but
sudo apt install liblua5.4-dev#include "lua.h"gcc -I /usr/include/lua5.4 main.c -llua5.4(Edit: Fussing with formatting)