Skip to content

SOL_LUAJIT not defined and not documented #1082

@piotr-piatkowski

Description

@piotr-piatkowski

I'm compiling with luajit-2.1, and I had problems with using jit module - it's not available even after I load it with open_libraries:

int main(int argc, char**argv) {
    sol::state lua;
    lua.open_libraries(
        sol::lib::base,
        sol::lib::jit
    );

    try {
        lua.safe_script("print('jit.version=' .. jit.version)");
    }
    catch(const sol::error &err) {
        cout << "Error: " << err.what() << endl;
    }
}

So this gives an error:

Error: sol: runtime error: [string "print('jit.version=' .. jit.version)"]:1: attempt to index global 'jit' (a nil value)

After some digging I found that I should define SOL_LUAJIT before including sol.hpp - and this helps and everything works fine, but shouldn't this be set automatically, or at least documented somewhere? I couldn't find any mention except for some closed issues discussions.

(BTW, why is safe_script throwing an exception? I expected it to just return protected_function_result - but it's throwing sol::error instead)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions