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
Create your own binding with swig #25
Comments
Add "#include "MyCode.h" to the top of your interface file and regenerate the bindings:
Also, you may not need to include ofMain.h if you're not using any openFrameworks classes, functions, etc. |
Also, you'll need to create an implementation for those functions & class methods. The example code is not actually tested. |
I updated the example in the readme which should actually compile now. |
Thanks again Dan, there is typographical error at
an extra i. |
I fixed it already. Lots of typos, should be fine now. |
It's working. |
Something more Dan, although the project has a successful compile with the following lua script:
I am taking the error:
|
Might be because the function name is wrong. It's actually: "my.myFunction" and the class constructor is "my.MyCoolClass". I'll update the example. |
Change to
taking the result:
|
Did you open your custom lua lib after initing the lua state? You have to do this every time you call init(). https://github.com/danomatika/ofxLua#opening-your-lua-library |
Yes, here is my ofApp.cpp file https://github.com/igoumeninja/Gea/blob/working_branch/src/ofApp.cpp. |
But not after this one: https://github.com/igoumeninja/Gea/blob/working_branch/src/ofApp.cpp#L37 :D Calling init() again completely clears the state. |
I add
at positions, but still got an error.
|
You broke it here: https://github.com/igoumeninja/Gea/blob/working_branch/src/MyBindings.i My earlier comment about adding the #include "MyCode.h" line didn't mean to replace all of the text with that, you still need to run the As it says in my readme updates, your interface file should contain this:
|
You can check what's loaded in the lua state by printing all the tables after init() and luaopen_my: |
Remove |
DONE, thanks a lot Dan. Have a nice evening. I getting out to a concert: https://www.youtube.com/watch?v=TfoisYwKAVg. Have a nice day! |
There's one last thing you'll need to update. See the latest version of the example MyBindings.i in https://github.com/danomatika/ofxLua#swig-interface I forgot to add the %includes SWIG needs in order to correctly handle std::string conversion to lua strings. I tested with you're code and the example now works correctly. Thanks for going through this so we know it works. |
Hi Dan, again,
I am trying to create my own binding by following your instruction. I am taking the following errors:
The project is here: https://github.com/igoumeninja/Gea/tree/working_branch
If you find some time to help, I 'll be greattful.
Thanks in advance
The text was updated successfully, but these errors were encountered: