lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Thanks for the reply.

My intention is to  use luac and bin2c and then include the resulting “string”. 

I did the experiments below to ensure I could compile everything correctly but it seems I am doing something wrong as the simple text.wlua does not run…

 

Hope you can help,

Bob

 

 

From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Antonio Scuri
Sent: 29 June 2009 19:41
To: 'Lua list'
Subject: RES: Embedding Lua / IUP

 

 Hi,

 

  There are many ways to do that. Some tools append the Lua code to the executable. Other tools compile the code and add them as include files in the source code. Which one you are trying to use?

 

  I use the second one because it works seamless in all platforms. You have to run luac to convert you lua files to bytecode, then use bin2c to convert it to a C function call.

 

  If this is what you want I can give you more details.

 

Best,

scuri

 

De: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] Em nome de Bob Hibberdine
Enviada em: segunda-feira, 29 de junho de 2009 13:07
Para: lua@bazar2.conectiva.com.br
Assunto: Embedding Lua / IUP

 

Hi,

 

I am hoping someone can help...

 

I have a quite large Lua / IUP script that I would like to make into an “executable” (Windows XP). To that end I thought I’d embed my lua script into a C program.

1.       Starting from scratch I found a simple example (“Hello, World!”) of doing this with plain Lua. This worked...

2.       Moving on to the next step I took a very simple IUP Lua example (text.wlua) and tried to get this working from C. This did not work..

3.       To check that I had included the right IUP libraries etc I tried building the  IUP example “sample.c” with the same VC project settings as #2. This worked.

 

The fact that #3 works suggests that I have all the right IUP libraries and dlls in all the right places. Which points the finger at the iuplua libraries.???

 

When I say it doesn’t work specifically the program just stops at getchar() (see code below) without anything else happening. The return value from  luaL_dofile is 1.

 

I am using

Microsoft visual studio 2005. The free version.

IUP 2.7.1 (IUP libraries are this version too)

Lua 5.1

Lua for Windows.

 

 

My very simple cpp code is a copy of lua_init.c from the IUP web site. See below:

 

Could the  problem be to do with calling conventions ? Visual C did not let me create a C project (only C++)  I don’t know. It has been a long time since I did any  windows programming (That’s why I am using Lua / IUP.!!)

 

 

Can anyone suggest anything or better still send me a working VC project (I live in hope J)

 

Many thanks

 

Bob

 

 

#include <stdio.h>

 

extern "C" {

      #include "lua.h"

      #include "lualib.h"

      #include "lauxlib.h"

}

#include <iup.h>

#include <iupcontrols.h>

 

#include <iuplua.h>

//#include <iupluacontrols.h>

 

 

 

lua_State* L;

 

int main ( int argc, char *argv[] )

{

 

  IupOpen(&argc, &argv);

//  IupControlsOpen();

 

  // Lua 5 initialization

  L = lua_open();  

  luaL_openlibs(L);

 

  iuplua_open(L);     

//  iupcontrolslua_open(L);

 

 // do other things, like running a lua script

luaL_dofile(L, "text.wlua");

//  IupMainLoop();

 

  lua_close(L);

 

  IupClose();

 

      /// pause

      printf( "Press enter to exit..." );

      getchar();

 

      return 0;

}

 

And text.wlua is

 

require( "iuplua" )

 

text = iup.text{value = "Write a text; press Ctrl-Q to exit"}

 

function text:k_any(c)

  if c == iup.K_cQ then

    return iup.CLOSE

  end

  return iup.DEFAULT

end

 

dlg = iup.dialog{text; title="IupText"}

 

dlg:showxy(iup.CENTER, iup.CENTER)

iup.SetFocus(text)

 

if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then

  iup.MainLoop()

end

 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
_____________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________