problems embedding lua
Perhaps, the loadstring() is defined in the liblualib library of basic functions. Are you linking that in as well?
are you using lua_loadString (note : *lua_*loadString) ?
from your original code, you seemed to just use "loadstring(..)"
from your original code, you seemed to just use "loadstring(..)"
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
That makes sense...
i added those files in src/lb to the project and rebuilt it. It prduced a new lua.lib file that was almost twice the size of the lua.lib I creaed before I added the files in src/lib...how do I tell it to create liblualib?
i added those files in src/lb to the project and rebuilt it. It prduced a new lua.lib file that was almost twice the size of the lua.lib I creaed before I added the files in src/lib...how do I tell it to create liblualib?
nekoflux
I tried both lua_loadstring(...) and loadstring(...); neither seems to work I keep getting an error:
error C2065: 'lua_loadstring' : undeclared identifier
*or*
error C2065: 'loadstring' : undeclared identifier
[edited by - nekoflux on February 5, 2004 3:32:51 AM]
error C2065: 'lua_loadstring' : undeclared identifier
*or*
error C2065: 'loadstring' : undeclared identifier
[edited by - nekoflux on February 5, 2004 3:32:51 AM]
nekoflux
I had no problems incorporating LUA 5 to my applications (or more exactly I solved them all myself). I never actually used any kind of loadstring() - I needed to load files only. But I think you can use lua_dostring(), but don''t forget to include lauxlib.h , where it is defined! LUA 5 itself has pretty limited loading functions (only some lua_load(), which I never used) and more of them exist in the aux library.
Society's never gonna make any progress until we all learn to pretend to like each other.
Hey Xerxes:
cool name, is that a reference the the xml parser or system shock2? thats my favorite game...
anyways, yeah I include 3 files,
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
ive tried loadfile(), lua_loadfile(), loadstring(..), dostring(..) none of them work, they all flag the same compile error.
I have both lua.lib and lualib.lib in the link options but still nothing
Its bizarre because I can call lua_open() lua_close(), lua_mathlibopen(), etc but none of the load functions seem to work..which leads me to believe that im missing a lib or didnt build those 2 libs correctly.
any clues whats up?
cool name, is that a reference the the xml parser or system shock2? thats my favorite game...
anyways, yeah I include 3 files,
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
ive tried loadfile(), lua_loadfile(), loadstring(..), dostring(..) none of them work, they all flag the same compile error.
I have both lua.lib and lualib.lib in the link options but still nothing
Its bizarre because I can call lua_open() lua_close(), lua_mathlibopen(), etc but none of the load functions seem to work..which leads me to believe that im missing a lib or didnt build those 2 libs correctly.
any clues whats up?
nekoflux
quote: Original post by nekoflux
Hey Xerxes:
cool name, is that a reference the the xml parser or system shock2? thats my favorite game...
Xerxes is a historical figure. You don''t think anybody makes up their own names any more, do you?
Perhaps you need lua_dostring (from lauxlib.h) rather than lua_loadstring ?
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
Well, I actually tried lua_dostring(L, "something") with lauxlib.h included and it worked without any problem.
BTW, thanks, I originally started using Xerxes nickname when I saw it in System Shock 2 (my favourite game too), and THEN I learnt about Xerxes, the Persian king. And XML parser? Never heard of (maybe because I''m not using XML).
BTW, thanks, I originally started using Xerxes nickname when I saw it in System Shock 2 (my favourite game too), and THEN I learnt about Xerxes, the Persian king. And XML parser? Never heard of (maybe because I''m not using XML).
Society's never gonna make any progress until we all learn to pretend to like each other.
yes, I''ve tried various combinations. I have tried several permutations of loadstring, dostring, etc, but none of them work. Here is my code again:
the above code compiles fine, but as soon as I uncomment any of the above 4 lines, i get one of these errors:
error C2065: ''lua_loadstring'' : undeclared identifier
error C2065: ''loadstring'' : undeclared identifier
error C2065: ''lua_dostring'' : undeclared identifier
error C2065: ''loadfile'' : undeclared identifier
what perplexes me is, I can call lua_close(), lua_open(), lua_iolibopen(), etc but I can''t call any of the functions that are commented out. why does the compiler only see some functions and not others?
help please
#include "stdafx.h"extern "C"{#include "lua.h"#include "lualib.h"#include "lauxlib.h"}int main(int argc, char* argv[]){ lua_State* luaVM = lua_open(); if (NULL == luaVM) { printf("Error Initializing lua\n"); return -1; } lua_baselibopen(luaVM); lua_iolibopen(luaVM); lua_strlibopen(luaVM); lua_mathlibopen(luaVM); char* strLuaInput = "a = 1 + 1;\n"; //loadstring(luaVM, strLuaInput); //lua_dostring("a = 1 + 1;\n"); //loadfile("a = 1 + 1;\n"); lua_close( luaVM ); return 0;}
the above code compiles fine, but as soon as I uncomment any of the above 4 lines, i get one of these errors:
error C2065: ''lua_loadstring'' : undeclared identifier
error C2065: ''loadstring'' : undeclared identifier
error C2065: ''lua_dostring'' : undeclared identifier
error C2065: ''loadfile'' : undeclared identifier
what perplexes me is, I can call lua_close(), lua_open(), lua_iolibopen(), etc but I can''t call any of the functions that are commented out. why does the compiler only see some functions and not others?
help please
nekoflux
quote: //lua_dostring("a = 1 + 1;\n");
Why don''t use lua_dostring(luaVM, "something")? I think luaVM is missing. That code worked absolutely fine to me (I copy-pasted it to a new project), without any problem.
And I think I finally figured out what''s wrong with your code. Are you sure you are using right headers? Aren''t those you use some kind of leftover after LUA 4? Make sure you are using the right ones. Because in the right ones, there is a line declaring:
LUALIB_API int lua_dostring (lua_State *L, const char *str);
(Copy-pasted)
So I suggest you completely remove both LUAs, download the most recent version from www.lua.org and reinstall it, because that should work.
Society's never gonna make any progress until we all learn to pretend to like each other.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement