0

I'm looking for a simple script language which I can compile easily by just putting the .h files under an include folder and the .c/.cpp files under a source directory. Something without any Makefile. Must be written in C/C++ rather C++.


Okay so LUA doesn't work, I need something which I can just call a simple method and it will handle a script file. Without any load from file methods in it, or atleast something which doesn't use the stdio.h.

Sampson
  • 265,109
  • 74
  • 539
  • 565
  • 5
    This isn't clear at all. Do you want a build program that automatically manages compiles, or do you just want a shell script in which you write gcc commands or something? – bmargulies Jan 29 '10 at 18:59
  • It's also unclear to me what's wrong with make - seems like either you're going to end up with a standard scripting language for your answer (and you'd also have make available) or you'll get something outlandish (and if you could install that, why not install make?). – Cascabel Jan 29 '10 at 19:01
  • @Jefromi - make is wrong because it's unneedingly complex.... – Kornel Kisielewicz Jan 29 '10 at 19:05
  • Ah. I guess. Never had a lot of trouble with a quick "build all the objects" + "build the main program" approach, but fair enough. – Cascabel Jan 29 '10 at 19:07
  • 2
    There is no language called C/C++. There is C, and there is C++. It is also possible to write code in the common subset of both languages that will compile in either. – KeithB Jan 29 '10 at 19:11
  • 1
    What's wrong with building the scripting engine seperately with whatever build tool it uses and then linking against the resulting library? That's how it is normally done... – Christoph Jan 29 '10 at 19:21
  • Please answer some of the questions. Do you mean a build program that manages compiles, or a scripting language of some sort? What do you mean by "without any Makefile"? What do you mean by C/C++, since there is no such thing, particularly as opposed to C++, and what must be written in? Do you need anything more than `gcc *.c *.cpp -I`? – David Thornley Jan 29 '10 at 19:59
  • What I wanted to do is to use a scripting language as a library in my application (which is intended to be for the DS). When compiling for the DS, you must use a specific compiler so when you link the library you won't get any problem. –  Jan 29 '10 at 19:59
  • @Tamir: A scripting language is not a library, so I'm no wiser. Do you want a scripting language in your app? Do you refer to the Nintendo DS? What platform are you compiling on? Please go through the questions in the comments, and edit your question to answer them. When in doubt, include too much detail rather than too little. I simply do not know what you're talking about, and therefore I can't help you. – David Thornley Jan 29 '10 at 20:05
  • Most scripting languages can be embedded into C or C++ thus they are libraries, which are linked to your application. But, for linking them to your application, you must compile them to work under your enviroment. I'm compiling for the Nintendo DS using it's toolchain. –  Jan 29 '10 at 20:24
  • @Tamir, this is still not enough information. What is the Nintendo DS toolchain? I doubt many of us have programmed on it. Does it use C, C++, or both? What would a DS cartridge need with a scripting language? Are you saying you just want to put the scripting language files into your source and include directories along with anything else (bearing in mind that it isn't a library if you do that), or did you want to make a library to link to? – David Thornley Jan 29 '10 at 20:30
  • I wanted to make a library to link to. I have already done that, I was just explaining what I meant. –  Jan 29 '10 at 20:32

3 Answers3

2

Lua is a simple lightweight scripting language that can be easily embedded into your application. It is written in C (I don't really understand what you mean by "Must be written in C/C++ rather C++").

You can simply add all files from the src directory except for lua.c and luac.c into your project and it should work.

Note that if you're including from a C++ file, you have to wrap includes in extern "C" block. The following compiles and links for me.

extern "C" {
#include <lua.h>
#include <lauxlib.h>
}

int main()
{
    lua_State* L = lua_open();
}
avakar
  • 32,009
  • 9
  • 68
  • 103
  • I added lua.c and luac.c and it has compiled, is it okay? I mean, should I use it and it won't have any problems? –  Jan 29 '10 at 19:46
  • Well, `lua.c` and `luac.c` both have `main` function, so I'm not sure how you linked it. They are command-line programs that execute lua scripts. You don't need them to embed lua into your application. – avakar Jan 29 '10 at 19:50
  • I yet did not link the library to my application. But yeah okay, I saw the entry point, I will just delete those files. –  Jan 29 '10 at 19:51
  • Argh, now it wouldn't link properly.. I wrote: lua_State* L = lua_open(); and the next error has popped: c:/Users/Tam/Desktop/LogicOS/source/logic_os.cpp:71: undefined reference to `luaL_newstate()' Its the same for all methods, maybe I should drop some parts that are using the C's IO function, or just change them to work with the DS toolchain. –  Jan 29 '10 at 20:35
  • That function is in `lauxlib.c`. Are you sure you're linking it too? – avakar Jan 29 '10 at 21:44
  • You will find the references to stdio.h in print.c and liolib.c . It is not hard to remove the io library and hacking the print function is pretty easy. – Nick Van Brunt Jan 29 '10 at 22:00
  • Hmm, I think my problem was the clash between .c functions to .cpp.. Some people have told me that it might cause linking problems.. Just one thing, if I add extern "C" will it affect linking somehow? –  Jan 30 '10 at 19:28
  • Oh nevermind, got it compiled. The command line forgot to report about some problems with some methods, fixed and re-compiled lua, and it finally fixed! –  Jan 30 '10 at 19:59
1

Try premake4. A lot easier to work with than plain Makefiles, and is quite portable indeed.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
0

I am sure I understand the context of your question since a script implies that it is interpreted yet you want to compile it...would CH Compiler do?

Hope this helps, Best regards, Tom.

t0mm13b
  • 34,087
  • 8
  • 78
  • 110
  • I suspect the OP means "with which" not "which", as in the script helps perform the compilation. – Cascabel Jan 29 '10 at 19:37
  • ...or since "lua" was the accepted answer, I guess the real meaning was a scripting language to embed into my application, and one which doesn't take any effort to integrate until the build pipeline? – Cascabel Jan 29 '10 at 20:34