[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: turnning lua code to executable in a C program
- From: Sean Conner <sean@...>
- Date: Mon, 24 Aug 2015 03:39:06 -0400
It was thus said that the Great Amir Ramezani once stated:
> hello,
> i want to turn a lua code in my application to executable!
> i've wrote a code from
> http://github.com/qtnc/lua2exe
> but it doesn't work
> this is my compiler class which bind's the script:
[ snip ]
> what is the problem here? and how can i fix it
First problem: the formatting. Horrible and extemely hard to read.
Second problem: no indication of what operating system you are using
(MS-DOS? AmigaOS? BeOS? VMS?)
Third problem: no indication of which C++ compiler you are using.
Fourth problem: no indication of what Lua version you are using.
Fifth problem: This isn't valid C++ code. For instance, this line:
buffer=malloc(bufferlen);
C++ mandates that you cast this to the proper type, so it should read
like:
buffer = (char *)malloc(bufferlen);
The C++ compiler you are using should have given a warning (or error---I'm
not terribly versed in C++, but know enough to get code compiled). Another
example: you have the following function:
int output(const char *scr,bool dbg)
{
// ...
preparename(scr);
}
scr is defined as a pointer to constant characters (characters that
read-only and cannot be changed). Yet the function for preparename():
void preparename (char* s)
{
char* c = strrchr(s,'.');
if (c)
{
*c=0;
}
while (*(++s))
{
if (*s=='/' || *s=='\\')
{
*s='.';
}
}
}
attempts to change it. Again, your C++ compiler should have warned you
about this as well.
Sixth: What you've given us is incomplete and can't even be compiled as
is (fifth problem not-withstanding) because of missing definitions. One
example is the definition of GlobalChunkInfo. Another is that you keep
using the variable 'l' for the Lua state, yet you don't have that variable
defined anywhere---for instance, your public method compiler::compile()
references 'l', but you don't define in in the function, the class, nor do
you pass it in as a parameter.
Seventh: You don't state what exactly your problem is.
I think you'll need to address these issue first before anyone can give
you more help with your issue.
-spc