diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-05 05:02:49 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | 5250cb90406693163763a214af95f670e0e3a4e0 (patch) | |
tree | 7025c762d4f53aebfdc140d615306f558fa9b69a /examples/hello_lua | |
parent | 3059b1cb8d701cf23f3e04a8a8fdcfcaa6a397fb (diff) |
Add cross compilation (mingw-w64 x86_64)
Currently only cross compiling from linux64 to win64 works.
Need to test cross compilation more, currently the cross compilation
uses same profile as GCC, is that correct?
Diffstat (limited to 'examples/hello_lua')
-rw-r--r-- | examples/hello_lua/.gitignore | 5 | ||||
-rw-r--r-- | examples/hello_lua/hello.lua | 1 | ||||
-rw-r--r-- | examples/hello_lua/project.conf | 8 | ||||
-rw-r--r-- | examples/hello_lua/src/main.cpp | 31 |
4 files changed, 45 insertions, 0 deletions
diff --git a/examples/hello_lua/.gitignore b/examples/hello_lua/.gitignore new file mode 100644 index 0000000..636c6b9 --- /dev/null +++ b/examples/hello_lua/.gitignore @@ -0,0 +1,5 @@ +# Compiled sibs files +sibs-build/ +compile_commands.json +tests/sibs-build/ +tests/compile_commands.json diff --git a/examples/hello_lua/hello.lua b/examples/hello_lua/hello.lua new file mode 100644 index 0000000..4601856 --- /dev/null +++ b/examples/hello_lua/hello.lua @@ -0,0 +1 @@ +print("inside lua!") diff --git a/examples/hello_lua/project.conf b/examples/hello_lua/project.conf new file mode 100644 index 0000000..e416497 --- /dev/null +++ b/examples/hello_lua/project.conf @@ -0,0 +1,8 @@ +[package] +name = "hello_lua" +type = "executable" +version = "0.1.0" +platforms = ["any"] + +[dependencies] +lua51 = "5.1.5" diff --git a/examples/hello_lua/src/main.cpp b/examples/hello_lua/src/main.cpp new file mode 100644 index 0000000..57f9194 --- /dev/null +++ b/examples/hello_lua/src/main.cpp @@ -0,0 +1,31 @@ +#include <stdio.h> +extern "C" { +#include <lua5.1/lua.h> +#include <lua5.1/lualib.h> +#include <lua5.1/lauxlib.h> +} +int main(int argc, char *argv[]) { + // Open lua + lua_State *L = lua_open(); + + // Load the libraries + luaL_openlibs(L); + + // Execution of a lua string + luaL_dostring(L, "print \"Yo dude\""); + + // Load a string and then execute it. + luaL_loadstring(L, "io.write(\"I'm here too\\n\")"); + lua_pcall(L, 0, LUA_MULTRET, 0); + + // Load from a file and then execute + if (luaL_loadfile(L, "hello.lua") == 0) { + // File loaded call it + lua_pcall(L, 0, LUA_MULTRET, 0); + } + + // Close lua + lua_close (L); + + return 0; +} |