Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Koneki » Compiling for Lua C API to call LibSndFile functions(Compiling for Lua C API to call LibSndFile functions)
Compiling for Lua C API to call LibSndFile functions [message #1500273] Fri, 05 December 2014 21:02 Go to next message
Krista Hill is currently offline Krista HillFriend
Messages: 5
Registered: December 2014
Junior Member
My issue is that I want to be able to use the Lua API for C to call functions in an external DLL. While I am new to Eclipse, I know the C API. So far I've been using MinGW to compile code along with Lua for Windows, but I'd prefer to use Eclipse.

To get started I wrote a simple "Hello World" application with a DLL that prints the greeting. To run the program under Lua I just type in the following, which works with Lua for Windows.

require("ExLib1")
hello()

To get where I am now with Eclipse, I started with the Eclipse-CDT package for 64 bit Windows and was able to use that to use the MinGW that I've known to compile the above DLL.

After adding in LDT, I tried the above Lua script the Lua interpreter resident to Eclipse chokes at the require and says the DLL is not valid. In digging some,

I'm guessing that this is a 32-bit / 64 bit fiasco. I'm looking for options to make this work. Advice on how to build against the resident interpreter would be appreciated.

BTW, my plans are to make use of a few functions in the LibSndFile library to do some work with sound files. I need to be able to write .wav files. If you know of Lua library for that, please let me know.

Re: Compiling for Lua C API to call LibSndFile functions [message #1502886 is a reply to message #1500273] Mon, 08 December 2014 02:34 Go to previous messageGo to next message
Krista Hill is currently offline Krista HillFriend
Messages: 5
Registered: December 2014
Junior Member
I think I just took two steps in the right direction:
1) I downloaded the 32 bit version of the CDT & Eclipse package

2) While I do have a Java JRE, it's 64 bit. In looking at the error message I noticed it referred to a local directory. So I downloaded a recent JRE (7u72) from Oracle. The .tar.gz version just has the JRE in standalone alone folder. I moved the JRE folder into the Eclipse. I next changed the JRE folder by removing the version number, changing it from jre1.7.0_72 to just jre.

Okay, now I have the 32-bit version of started. I added the LDT plugin using the Help/Add Software feature, without issue.

Starting to take my next step...
Re: Compiling for Lua C API to call LibSndFile functions [message #1502909 is a reply to message #1502886] Mon, 08 December 2014 02:59 Go to previous messageGo to next message
Krista Hill is currently offline Krista HillFriend
Messages: 5
Registered: December 2014
Junior Member
Just took a few more steps...

3) After some tweaks, Eclipse was able to build the DLL
o Added the Include folder in the Lua for Windows windows to the build settings
o Also added the lua51 library to the build settings
o Eclipse has the DLL name prepended with "lib" which is a pain as the Lua opener function
that I wrote isn't expecting that name. I manually removed the prepended "lib" for now...

4) I'm not sure yet how to coordinate library search paths yet, but I created a new Lua project folder, manually copied in the library and to my relief... it works...

Here is the Lua code... The library source (ExLib1.c) is attached...

local function main()
require("ExLib1")
hello()
end
main()

And here's the result...

Running luaopen_ExLib1
Hello World!

Yeah!! Now I have something that I can use to learn about Eclipse and more about Lua... I feel quite relieved... Smile

  • Attachment: ExLib1.c
    (Size: 0.56KB, Downloaded 217 times)

[Updated on: Mon, 08 December 2014 03:19]

Report message to a moderator

Re: Compiling for Lua C API to call LibSndFile functions [message #1502914 is a reply to message #1502909] Mon, 08 December 2014 03:02 Go to previous message
Krista Hill is currently offline Krista HillFriend
Messages: 5
Registered: December 2014
Junior Member
The JNLua package is something new to me... I'm sure I'll be reading more... Perhaps in time I'll have a full 64-bit environment. For now I'll make the most of what I have in front of me... Smile
Previous Topic:Autocompletion for external API
Next Topic:Koneki OMA DM Simulator Source code
Goto Forum:
  


Current Time: Thu Apr 18 00:21:44 GMT 2024

Powered by FUDForum. Page generated in 0.02780 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top