I need to use lua language in my Qt-application. I add necessary files into my project and write this code:
#include "stdafx.h"
#include "podkl.h"
#include <QtWidgets/QApplication>
#pragma comment(lib, "lua52.lib")
#include <lua.hpp>
int Write(lua_State* s) {
return 0;
}
int main(int argc, char *argv[]) {
PODKL w;
w.show();
lua_State* s = luaL_newstate();
luaopen_base(s);
lua_pcall(s, 0, 0, 0);
//lua_register(s, "Write", Write);
return a.exec();
}
#include "stdafx.h"
#include "podkl.h"
#include <QtWidgets/QApplication>
#pragma comment(lib, "lua52.lib")
#include <lua.hpp>
int Write(lua_State* s) {
return 0;
}
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
PODKL w;
w.show();
lua_State* s = luaL_newstate();
luaopen_base(s);
lua_pcall(s, 0, 0, 0);
//lua_register(s, "Write", Write);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
49068-clip-32kb.png
If I compile the program that way I have a linker message:
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol lua_pcall referenced in function main
1>D:\Programming\VisualStudio\Projects\STUDYING\PO DKL\x64\Debug\\PODKL.exe : fatal error LNK1120: 1 unresolved externals
But if I launch it this way:
//lua_pcall(s, 0, 0, 0);
lua_register(s, "Write", Write);
//lua_pcall(s, 0, 0, 0);
lua_register(s, "Write", Write);
To copy to clipboard, switch view to plain text mode
Then I get an error message: "Unhandled exception at 0x00007FFDA7120810 (lua52.dll) in PODKL.exe: 0xC0000005: Access violation reading location 0x0000002F0ABDA198."
I have tried to launch lua from usual console project. And I have done it. Don't know why I can't do it on Qt.
What should I do to use lua on Qt-application?
(Win 8.1, x64)
Bookmarks