digitalmars.D.ldc - luaJIT FFI
- andi (20/20) Apr 10 2016 hey everyone,
- Dan Olson (8/15) Apr 11 2016 Hi,
- andi (10/27) Apr 12 2016 Im using win7 and win10, visual studio 2013 + VisualD and
- Dan Olson (21/48) Apr 14 2016 I haven't used Lua but just looking at your example core.lua, it looks
- andi (10/56) Apr 27 2016 sry i was busy with work, but i got the error handling working
- andi (17/79) Apr 28 2016 maybe to clarify, it works when i add a linker option:
- Johan Engelen (5/8) Apr 28 2016 Could you try a more recent LDC version (0.17 perhaps) to make
hey everyone, this is my first thread, im pretty new to D but i already appreciate it ;) so i got derelict-lua up and running with lua5.1. took a while to downgrade it to 5.1, but its working now. next i did was to call into luaJIT from D, working as expected. then i thought, ok no problem to do vice versa, but i ran into problems. im not sure how to properly export those symbols into c global namespace, or maybe i get something totally wrong. doing extern (C) and defining my functions, but im having troubles to call them via luaJIT FFI. as you see, i didnt spend too much time yet on that problem, but im hoping someone was doing the same thing already before me, and could spare me wasting too much time on it? i have a work around for this, using C compiler, but i would prefer to not touch C anymore. thx
Apr 10 2016
andi <cadetschimmel gmail.com> writes:next i did was to call into luaJIT from D, working as expected. then i thought, ok no problem to do vice versa, but i ran into problems. im not sure how to properly export those symbols into c global namespace, or maybe i get something totally wrong. doing extern (C) and defining my functions, but im having troubles to call them via luaJIT FFI.Hi, Can you post details on the problem? Is it a link time error or runtime? OS (e.g Linux)? Is main controlled by Lua (not using a D main)? If so, you will need to initialize D runtime (rt_init or Runtime.initialize). -- Dan
Apr 11 2016
On Monday, 11 April 2016 at 15:18:47 UTC, Dan Olson wrote:andi <cadetschimmel gmail.com> writes:Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc. and im using luaJIT 2.1 beta2 i think its easier to simply upload everything i got so far, so here it is my current project: http://seed-engine.com/downloads/seed2_sdk.zip in src/seed2/main.d is my int main() in bin/core/core.lua im testing luaJITs FFI thx againnext i did was to call into luaJIT from D, working as expected. then i thought, ok no problem to do vice versa, but i ran into problems. im not sure how to properly export those symbols into c global namespace, or maybe i get something totally wrong. doing extern (C) and defining my functions, but im having troubles to call them via luaJIT FFI.Hi, Can you post details on the problem? Is it a link time error or runtime? OS (e.g Linux)? Is main controlled by Lua (not using a D main)? If so, you will need to initialize D runtime (rt_init or Runtime.initialize).
Apr 12 2016
andi <cadetschimmel gmail.com> writes:On Monday, 11 April 2016 at 15:18:47 UTC, Dan Olson wrote:I haven't used Lua but just looking at your example core.lua, it looks just like Lua FFI documentation for calling C code. Can you post the actual error you see? I extracted interesting parts of your zip file. I note that your main.d has a D main() function, so you don't need to call rt_init(). -- from core.lua -- local ffi = require("ffi") ffi.cdef[[ void call_dfunction(); ]] print("hello from luaJIT") ffi.C.call_dfunction() -- from main.d -- extern (C) public void call_dfunction() { writeln("call_dfunction"); } You don't need public though. -- Danandi <cadetschimmel gmail.com> writes:Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc. and im using luaJIT 2.1 beta2 i think its easier to simply upload everything i got so far, so here it is my current project: http://seed-engine.com/downloads/seed2_sdk.zip in src/seed2/main.d is my int main() in bin/core/core.lua im testing luaJITs FFI thx againnext i did was to call into luaJIT from D, working as expected. then i thought, ok no problem to do vice versa, but i ran into problems. im not sure how to properly export those symbols into c global namespace, or maybe i get something totally wrong. doing extern (C) and defining my functions, but im having troubles to call them via luaJIT FFI.Hi, Can you post details on the problem? Is it a link time error or runtime? OS (e.g Linux)? Is main controlled by Lua (not using a D main)? If so, you will need to initialize D runtime (rt_init or Runtime.initialize).
Apr 14 2016
On Friday, 15 April 2016 at 04:23:44 UTC, Dan Olson wrote:andi <cadetschimmel gmail.com> writes:sry i was busy with work, but i got the error handling working now. i refactored the code a bit as well, the interesting part in D is now in script.d. http://seed-engine.com/downloads/seed2_sdk.zip when i try to call call_dfunction i get the error message: cannot resolve symbol 'call_dfunction': procedure could not be found greetings, AndiOn Monday, 11 April 2016 at 15:18:47 UTC, Dan Olson wrote:I haven't used Lua but just looking at your example core.lua, it looks just like Lua FFI documentation for calling C code. Can you post the actual error you see? I extracted interesting parts of your zip file. I note that your main.d has a D main() function, so you don't need to call rt_init(). -- from core.lua -- local ffi = require("ffi") ffi.cdef[[ void call_dfunction(); ]] print("hello from luaJIT") ffi.C.call_dfunction() -- from main.d -- extern (C) public void call_dfunction() { writeln("call_dfunction"); } You don't need public though.andi <cadetschimmel gmail.com> writes:Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc. and im using luaJIT 2.1 beta2 i think its easier to simply upload everything i got so far, so here it is my current project: http://seed-engine.com/downloads/seed2_sdk.zip in src/seed2/main.d is my int main() in bin/core/core.lua im testing luaJITs FFI thx again[...]Hi, Can you post details on the problem? Is it a link time error or runtime? OS (e.g Linux)? Is main controlled by Lua (not using a D main)? If so, you will need to initialize D runtime (rt_init or Runtime.initialize).
Apr 27 2016
On Wednesday, 27 April 2016 at 10:19:18 UTC, andi wrote:On Friday, 15 April 2016 at 04:23:44 UTC, Dan Olson wrote:maybe to clarify, it works when i add a linker option: -L/export:call_dfunction the code in Script.d: extern(C) void call_dfunction() { printf("call_dfunction\n"); } using export keyword instead of the linker flag doesnt work: extern(C) export void call_dfunction() { printf("call_dfunction\n"); } would be really tedious if i had to update linker flags everytime i want to expose a new function greetings, Andiandi <cadetschimmel gmail.com> writes:sry i was busy with work, but i got the error handling working now. i refactored the code a bit as well, the interesting part in D is now in script.d. http://seed-engine.com/downloads/seed2_sdk.zip when i try to call call_dfunction i get the error message: cannot resolve symbol 'call_dfunction': procedure could not be found greetings, AndiOn Monday, 11 April 2016 at 15:18:47 UTC, Dan Olson wrote:I haven't used Lua but just looking at your example core.lua, it looks just like Lua FFI documentation for calling C code. Can you post the actual error you see? I extracted interesting parts of your zip file. I note that your main.d has a D main() function, so you don't need to call rt_init(). -- from core.lua -- local ffi = require("ffi") ffi.cdef[[ void call_dfunction(); ]] print("hello from luaJIT") ffi.C.call_dfunction() -- from main.d -- extern (C) public void call_dfunction() { writeln("call_dfunction"); } You don't need public though.andi <cadetschimmel gmail.com> writes:Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc. and im using luaJIT 2.1 beta2 i think its easier to simply upload everything i got so far, so here it is my current project: http://seed-engine.com/downloads/seed2_sdk.zip in src/seed2/main.d is my int main() in bin/core/core.lua im testing luaJITs FFI thx again[...]Hi, Can you post details on the problem? Is it a link time error or runtime? OS (e.g Linux)? Is main controlled by Lua (not using a D main)? If so, you will need to initialize D runtime (rt_init or Runtime.initialize).
Apr 28 2016
On Tuesday, 12 April 2016 at 09:23:00 UTC, andi wrote:Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc.Could you try a more recent LDC version (0.17 perhaps) to make sure this hasn't been resolved already? Thanks, Johan
Apr 28 2016
On Thursday, 28 April 2016 at 15:38:44 UTC, Johan Engelen wrote:On Tuesday, 12 April 2016 at 09:23:00 UTC, andi wrote:i found an older bug report, saying that one should use a def file for the linker. i noticed i have the same issue with dmd, so, nevermind! also regarding 0.17: im too lazy currently to compile that version, i couldnt find it anywhere precompiled for vs2013Im using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc.Could you try a more recent LDC version (0.17 perhaps) to make sure this hasn't been resolved already? Thanks, Johan
Apr 28 2016
On Thursday, 28 April 2016 at 20:34:05 UTC, andi wrote:also regarding 0.17: im too lazy currently to compile that version, i couldnt find it anywhere precompiled for vs2013We do not provide official builds with vs2013 any more. We strongly recommend to use vs2015. Regards, Kai
Apr 29 2016
On Thursday, 28 April 2016 at 15:38:44 UTC, Johan Engelen wrote:On Tuesday, 12 April 2016 at 09:23:00 UTC, andi wrote:IMHO it is a bug. No code in LDC checks for protection.kind == PROTexport or isExport(). Using a def file is currently the only solution. Regards, KaiIm using win7 and win10, visual studio 2013 + VisualD and ldc2-0.15.2-beta2-win64-msvc.Could you try a more recent LDC version (0.17 perhaps) to make sure this hasn't been resolved already? Thanks, Johan
Apr 29 2016