-
-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
require('libraryName') #90
Comments
I have thought about making a
I have no idea how I'd make the other 2 work. In all honestly, I'd probably just call |
I would love to see |
Question: what happens if this fails? Do we just toss an error? |
Nevermind, I'm a dumb. Of course we just lua_error out. |
Lol, sounds good to me. I can't imagine it failing for too many reasons. |
You're all set:
|
You can also |
This is really cool and I will pick it up once I get sol compiling on windows. |
Hi, I think I have a similar issue. I need to run a torch/luajit script from a C++ program and have just started learning about lua C api and sol2 library. My script initially looks like:
Can you give an example how the 'require' portion of my script would work using sol2? |
I don't know where If you need exactly those libraries, try just running Note that even if sol2 doesn't do exactly what you want, if you do it yourself using the C API and find out how you can show me and I can spend some time working it into the library. |
Hi @ThePhD . Thank you for your reply. So these nn, cunn, cudnn are packages that gets installed by luarocks during the torch installation process. Luarocks calls 'make' on these folders: https://github.com/torch/distro/tree/master/extra. I am not sure where exactly these packages are lying. Here is the installation script: https://github.com/torch/distro/blob/master/install.sh I don't know if that helps (i'm a beginner) but my end goal is to write a C++ command line interface that does the following:
An example that does something similar is the torch-android demo and it's relevant code is here. The torch android demo says
So I'm wondering if there is a way I can use package.loader in sol2 that can load the require 'nn', 'cunn' packages before my lua script is run. |
Here's an error I get when I compiled the C++ program loading a lua script with those require 'nn', require 'cunn' lines: |
Here is how I load libraries: sol::state lua;
lua.open_libraries(sol::lib::base, sol::lib::package);
const std::string package_path = lua["package"]["path"];
lua["package"]["path"]
= package_path + (!package_path.empty() ? ";" : "") + test::scripts_path("proc/valid/") + "?.lua"; The |
Hi @Nava2 , thanks for your reply. I did a luarocks path and got the following:
I browsed to |
Does this help? |
@Nava2 Sorry, that didn't really help. Like I understand in my case, it could be
|
Close, you'd want to do: lua["package"]["path"] = package_path + ";/usr/local/share/lua/5.1/?/?.lua"; |
@Nava2 Sorry for a late reply. Was working on something different. I tried your suggestion. However, it loads the exact same paths as this line does
Eitherway, I get the following error:
The error specifically happens in the lines - require 'nn', require 'cunn', require 'cudnn' - in the lua script. I have made sure the path for those modules are lib package. Any help is appreciated. |
What does the lua code Could you show your full (relevant) code? |
@Nava2
Here is the C++ code:
And here's my build command:
Following is the output of print(package.path) before I get the error:
|
And you've verified the package |
@Nava2 I actually don't have a |
Is there a way to have sol2 make available lua-written libraries for "include"?
For example, I have a library I would like to use called "differed". It consists of one file "differed.lua" but expects to be required:
local deferred = require('deferred')
. I would like a way to do something similar tolua.open_libraries
on the file and have it available forrequire
. Is this possible with sol2?The text was updated successfully, but these errors were encountered: