Lua-Cjson cannot locate symbol "floor" in Termux
cattokomo opened this issue · comments
You will need to link with libm (-lm
) for the floor
function.
How?
there's no option by default to link mathlib because we can't add custom compile flags by default.
there's a module that provides custom build. https://github.com/osch/luarocks-build-extended
first install the module from luarocks
you need to specify flags by libflag_extras. also set build type type = "extended"
so i edited my rockspec and added flags
package = "lua-cjson"
version = "2.1.0.10-1"
source = {
url = "git+https://github.com/openresty/lua-cjson",
tag = "2.1.0.10",
}
description = {
summary = "a fast json encoding/parsing module",
detailed = [[
the lua cjson module provides json support for lua. it features:
- fast, standards compliant encoding/parsing routines
- full support for json with utf-8, including decoding surrogate pairs
- optional run-time support for common exceptions to the json specification
(infinity, nan,..)
- no dependencies on other libraries
]],
homepage = "http://www.kyne.com.au/~mark/software/lua-cjson.php",
license = "mit"
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "extended",
modules = {
cjson = {
sources = { "lua_cjson.c", "strbuf.c", "fpconv.c" },
defines = {
-- luarocks does not support platform specific configuration for solaris.
-- uncomment the line below on solaris platforms if required.
-- "use_internal_isinf"
}
}
},
install = {
lua = {
["cjson.util"] = "lua/cjson/util.lua"
},
bin = {
json2lua = "lua/json2lua.lua",
lua2json = "lua/lua2json.lua"
}
},
-- override default build options (per platform)
platforms = {
linux = { modules = { cjson = { variables = {
libflag_extras = {
"-lm", ""
}
} } } }
},
copy_directories = { "tests" }
}
-- vi:ai et sw=4 ts=4:
and then install
luarocks install lua-cjson-2.1.0.10-1.rockspec
i tested on my device and it works well.
I have found the solution, so you don't need to. I'm closing this issue to prevent any other answers