So, I'm experimenting with some things, and if it works out it should be pretty awesome, but I'm having trouble.
I'd need to require a C file, and a C header file of course, but I cannot seem to find a way to do this in Lua. I know there is a way to write C with Lua, but I can't find anything on that either.
So, is it possible to require a C file with Lua? Require didn't work for me, and neither did dofile.
There might be a really obvious answer that I can't find
Thanks!
Require a C file in Lua?
Require a C file in Lua?
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Require a C file in Lua?
You could do io.open ( or love.filesystem. whatever...) along with this. It's worth a try, at the least.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- NightKawata
- Party member
- Posts: 294
- Joined: Tue Jan 01, 2013 9:18 pm
- Location: Cyberspace, Room 6502
- Contact:
Re: Require a C file in Lua?
davisdude just what the fuck
but anyways...
LuaJIT's FFI Library?
That's about as good as C with Lua gets. (At least, if you're doing what I think you are)
but anyways...
LuaJIT's FFI Library?
That's about as good as C with Lua gets. (At least, if you're doing what I think you are)
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Re: Require a C file in Lua?
What do you mean? I don't see what's wrong with it...NightKawata wrote:davisdude just what the fuck
but anyways...
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: Require a C file in Lua?
I beleive by "require" eamonn means "load the executable code".
SHORT ANSWER: You don't.
Long answer: You need to compile the file first to a dymanically linked library, which would be .dll for Windows and .so for *nix, and then you can include it, and you would not need a header for it. Writing workable C code more complex than Hello World is already pretty hard, yet making a requireable library ain't that simple: to be requireable, library must have C Lua functions (for the lack of better term), that is callable Lua functions written in C which you hook up to the Lua. So it must strictly follow that big hardly documented "Using Lua In C" thing, which is an instant warranty of having to deal with really complicated matters. And, when you compile it, you must only include Lua headers but not link the Lua binaries to it, otherwise real Lua will fail to require this compiled library.
You really better off with LuaJIT, even though it's bad. If you want C code that bad, just write your entire app in C, and use liballeg as a framework instead of LÖVE.
SHORT ANSWER: You don't.
Long answer: You need to compile the file first to a dymanically linked library, which would be .dll for Windows and .so for *nix, and then you can include it, and you would not need a header for it. Writing workable C code more complex than Hello World is already pretty hard, yet making a requireable library ain't that simple: to be requireable, library must have C Lua functions (for the lack of better term), that is callable Lua functions written in C which you hook up to the Lua. So it must strictly follow that big hardly documented "Using Lua In C" thing, which is an instant warranty of having to deal with really complicated matters. And, when you compile it, you must only include Lua headers but not link the Lua binaries to it, otherwise real Lua will fail to require this compiled library.
You really better off with LuaJIT, even though it's bad. If you want C code that bad, just write your entire app in C, and use liballeg as a framework instead of LÖVE.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Require a C file in Lua?
Or Alien. Yet, it needs dynamic libs too.
Note: Totally unrelated, yet you might find some interest in it.
Note: Totally unrelated, yet you might find some interest in it.
Who is online
Users browsing this forum: Google [Bot] and 4 guests