Git Product home page Git Product logo

Comments (8)

jugglerchris avatar jugglerchris commented on July 19, 2024 2

Having done some investigation, I think the fix is to the end application.

The ideal fix would be the export-executable-symbols, which is available on nightly but not yet on stable - so if you're using nightly, passing -Z export-executable-symbols to cargo should make it work.

Until that's available, you can do it by adding linker flags. If I add println!("cargo:rustc-link-arg-examples=-Wl,-export-dynamic"); to rlua's build.rs, then for example target/debug/examples/repl has Lua (and other) symbols exported. For an end executable, you'd use rustc-link-arg-bins or similar. Unfortunately the specific linker option needed may vary for different platforms (this was on Linux).

from rlua.

xHyroM avatar xHyroM commented on July 19, 2024 1

@devzf i dont think rlua is dead, @jugglerchris do a great job here

from rlua.

jugglerchris avatar jugglerchris commented on July 19, 2024

I think the problem (similar to #264) is that we're not exporting the lua symbols. A workaround may be using the system-lua54 feature (and disabling default features), which would use a Lua library installed on your system instead of compiling one in.

I need to work out the linker options to export the Lua symbols to get it to work with the builtin Lua.

from rlua.

xHyroM avatar xHyroM commented on July 19, 2024

Thanks, i'll use nightly version for now 😅

from rlua.

bigmstone avatar bigmstone commented on July 19, 2024

I, too, am working through this issue. Had used -export_dynamic (MacOS is oh so slightly difficult different...) which does include some of the required symbols but I'm still missing luaL_openlibs. I'm attempting to use this with http Lua library.

For completeness sake w/o exporting dynamic it is failing earlier:

runtime error: error loading module 'lpeg' from file '/opt/homebrew/lib/lua/5.4/lpeg.so':
        dlopen(/opt/homebrew/lib/lua/5.4/lpeg.so, 0x0006): symbol not found in flat namespace '_lua_settable'

With exporting dynamic:

runtime error: error loading module '_cqueues' from file '/opt/homebrew/lib/lua/5.4/_cqueues.so':
        dlopen(/opt/homebrew/lib/lua/5.4/_cqueues.so, 0x0006): symbol not found in flat namespace '_luaL_openlibs'

Since luaL_openlibs is made available through the rlua-lua54-sys crate I thought linking on the Rust side with -C link-dead-code would fix this but it didn't.

$ nm ./target/debug/rtest | rg luaL_openlibs

$

I'm still working through this, but adding my findings as well to this issue if someone had a quick fix.

This is working fine w/ system Lua so it's not a blocker but would be nice to use the embedded Lua.

from rlua.

devzf avatar devzf commented on July 19, 2024

I would recommend switching to mlua. it doesn't have those problems.
rlua unfortunaly is dead.

from rlua.

jugglerchris avatar jugglerchris commented on July 19, 2024

@bigmstone Thanks for reporting your findings!
It may be that rlua needs to include references to functions it doesn't otherwise use (maybe especially in C source files that aren't otherwise referenced) for this case.

from rlua.

khvzak avatar khvzak commented on July 19, 2024

rlua is going to be deprecated soon in favour of mlua. See https://github.com/mlua-rs/mlua/blob/master/FAQ.md#loading-a-c-module-fails-with-error-undefined-symbol-lua_xxx-how-to-fix about about undefined symbols error.

from rlua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.