PeterMish
20th June 2015, 14:29
Hello everyone, for the past 2 days Ive been trying to get the lua api into the QTCreator suite for a project I'm currently undertaking.
The issue is I cannot for the life of me figure out how it's done.
So for further reference and help for others with the same issues, I want to make this thread.
Our starting position is this:- (Directories are irrelevant at this point)
We have an installed and working version of Lua 5 for windows.
We have an installed and working version of QTCreator 5
Lets keep things as basic as we can get it.
OUR GOAL: To be able to run/compile a lua application under C++ with QTCreator through the windows 8.1 environment.
If someone can help me achieve this that'd be tops.
I will be updating this post as progress ensues.
Thankyou for reading, and thankyou moreso for helping.
PROGRESS HAS ENSUED
Alright, in order to make lua work and compile with QTCreator we simply do the following steps (props to ChrisW67 from another thread for having the correct solution)
This will be done from my point of view and understanding.
STEP1: put all the important files from your lua installation into the folder of your choice.
The requirements for this folder are that it have no spaces, and for ease of use, make it a short name, such as Lua, Luas or ass, etc etc etc.
the files should be as follows.
lauxlib.h
lua.h
lua.hpp
luaX.X.dll
luaX.X.lib
luaXX.dll
luaXX.lib
luaconf.h
lualib.h
Where X is the version number. For my case I am using lua5.1 so the screenshot of my folder is as follows
http://puu.sh/ivZhs/bdfd8c867d.png (the forum is slightly buggy, this is a puush, google it, I'm not shady I promise)
Ok, that's step 1.
Now, STEP 2:
Go on and create your project, although unconfirmed for other ways, my way for doing this is as follows.
Hit NEW
11227
Hit Choose...
11228
Give it a name
11229
This part I'm not sure how to operate so I leave it as it is. It should be fine for you as well. I have Visual Studio installed so it has a lot of "features" and such. Should be relatively irrelevant if your QT5 installation is stock standard. Not sure how to help the special snowflakes, but they should know what they're doing.
Regardless, hit Next.
11230
Hit Next.
11231
(I can only attach 5 files for the post)
Hit Finish.
11232
This is our end result right now. Congratulations, that's step 2.
11233
Phew, we're getting there.
STEP 3:
Go to your .pro file.
It's selected in the screenshot above.
This next bit is going to make anyone who knows what they're doing cringe, but it worked and you are advised to use your own brain on this one.
Copy this
TEMPLATE = app
TARGET = test
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += C:/Lua/include
LIBS += -LC:/Lua -lluaXX
# Input
SOURCES += main.cpp
click once in the text area for the .pro file
Hold CTRL and press A
Hold CTRL and press V
Edit pieces as necessary.
â–ˆ is a path pointing to your lua files in that folder I showed you earlier
â–ˆ is the version number with is associated with the red one I showed you in step 1
Now to prove this works, we have a small piece of code that compiles and recognises some of our nice little lua segments.
this is our sample application
Same deal as before, CTRL+C CTRL+A CTRL+V
This time we're sending the letters to main.cpp
#include <QCoreApplication>
#include <lua.hpp>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
lua_State* s = luaL_newstate();
luaopen_base(s);
lua_pcall(s, 0, 0, 0);
int result = a.exec();
lua_close(s);
return result;
}
So to summarize:
11234
This is our final result and to prove it compiles
The little bar on the bottom right is green and full, everything is adequate.
11235
The issue is I cannot for the life of me figure out how it's done.
So for further reference and help for others with the same issues, I want to make this thread.
Our starting position is this:- (Directories are irrelevant at this point)
We have an installed and working version of Lua 5 for windows.
We have an installed and working version of QTCreator 5
Lets keep things as basic as we can get it.
OUR GOAL: To be able to run/compile a lua application under C++ with QTCreator through the windows 8.1 environment.
If someone can help me achieve this that'd be tops.
I will be updating this post as progress ensues.
Thankyou for reading, and thankyou moreso for helping.
PROGRESS HAS ENSUED
Alright, in order to make lua work and compile with QTCreator we simply do the following steps (props to ChrisW67 from another thread for having the correct solution)
This will be done from my point of view and understanding.
STEP1: put all the important files from your lua installation into the folder of your choice.
The requirements for this folder are that it have no spaces, and for ease of use, make it a short name, such as Lua, Luas or ass, etc etc etc.
the files should be as follows.
lauxlib.h
lua.h
lua.hpp
luaX.X.dll
luaX.X.lib
luaXX.dll
luaXX.lib
luaconf.h
lualib.h
Where X is the version number. For my case I am using lua5.1 so the screenshot of my folder is as follows
http://puu.sh/ivZhs/bdfd8c867d.png (the forum is slightly buggy, this is a puush, google it, I'm not shady I promise)
Ok, that's step 1.
Now, STEP 2:
Go on and create your project, although unconfirmed for other ways, my way for doing this is as follows.
Hit NEW
11227
Hit Choose...
11228
Give it a name
11229
This part I'm not sure how to operate so I leave it as it is. It should be fine for you as well. I have Visual Studio installed so it has a lot of "features" and such. Should be relatively irrelevant if your QT5 installation is stock standard. Not sure how to help the special snowflakes, but they should know what they're doing.
Regardless, hit Next.
11230
Hit Next.
11231
(I can only attach 5 files for the post)
Hit Finish.
11232
This is our end result right now. Congratulations, that's step 2.
11233
Phew, we're getting there.
STEP 3:
Go to your .pro file.
It's selected in the screenshot above.
This next bit is going to make anyone who knows what they're doing cringe, but it worked and you are advised to use your own brain on this one.
Copy this
TEMPLATE = app
TARGET = test
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += C:/Lua/include
LIBS += -LC:/Lua -lluaXX
# Input
SOURCES += main.cpp
click once in the text area for the .pro file
Hold CTRL and press A
Hold CTRL and press V
Edit pieces as necessary.
â–ˆ is a path pointing to your lua files in that folder I showed you earlier
â–ˆ is the version number with is associated with the red one I showed you in step 1
Now to prove this works, we have a small piece of code that compiles and recognises some of our nice little lua segments.
this is our sample application
Same deal as before, CTRL+C CTRL+A CTRL+V
This time we're sending the letters to main.cpp
#include <QCoreApplication>
#include <lua.hpp>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
lua_State* s = luaL_newstate();
luaopen_base(s);
lua_pcall(s, 0, 0, 0);
int result = a.exec();
lua_close(s);
return result;
}
So to summarize:
11234
This is our final result and to prove it compiles
The little bar on the bottom right is green and full, everything is adequate.
11235