It has to be linked. I downloaded project (.c and .h) files and .dll, .lib. .pdb. Then included it to my project. How to check if the .obj file is linked or no?
I checked the 's' with debugger. It wasn't NULL
It has to be linked. I downloaded project (.c and .h) files and .dll, .lib. .pdb. Then included it to my project. How to check if the .obj file is linked or no?
I checked the 's' with debugger. It wasn't NULL
Last edited by Defake; 14th June 2015 at 08:14.
Why when I create a simple console project, include lua files and turn it on, everything is ok.
But when I create qt project and do exactly the same, I get errors about unresolved external..
Why?? I hate it already >_<
My guess is, unsurprisingly, that the program crashes because the link failed to find exported Lua symbols. Frankly, I am surprised you got an executable out at all: do a completely clean build first. Check that you have linked the lua51 library through the LIBS pro file variable ( or whatever the Visual Studio obscured equivalent is).
No, I couldn't seem to add LINK line properly.
That are my efforts:
Qt Code:
LIBS += -L"$$PWD/lua/lua5.3.0.lib" LIBS += -L"$$PWD/lua/" -llua5.3.0 LIBS += L"$$_PRO_FILE_PWD_/lua" -llua LIBS += L"$$_PRO_FILE_PWD_/lua/" -llua.dll (And other looks like this variations)To copy to clipboard, switch view to plain text mode
But no one works. How to do it?
So exactly what are you doing to "include lua files"? The header files, the .c / cpp files, what? I think that when you create your Qt project you simply aren't compiling and linking the .c / .cpp file from the lua distro that contains the unresolved call.Why when I create a simple console project, include lua files
The files shown in your screen shot are named "lua51.lib and .dll, not "lua.lib" and "lua.dll" so these LIBS statements refer to non-existent files.LIBS += L"$$_PRO_FILE_PWD_/lua" -llua
LIBS += L"$$_PRO_FILE_PWD_/lua/" -llua.dll
I've alreadly downloaded new version lua (5.3.0). What exactly I do now:
Create Qt project in Visual stuido. Change x32 to x64 and check if the project launches correctly.
After checking I add into the project folder (in the windows explorer) a new folder "lua" and put into this all necessary lua-files (lua .c, .h, one .hpp, .lib, .dll and .exe files). Then I create into solution explorer (in Visual Studio) a new folder "lua" and put (drag n drop) into this all files from the folder "lua" in the windows explorer.
Then I include .hpp file (that contains including lua.h, lualib.h and lauxlib.h) and create new variable lua_State.
What I have at this moment:
111.jpg
Then it seems I have to open QtCreator and adjust .pro file, but my results I've posted above.
How to adjust it properly?
Last edited by Defake; 15th June 2015 at 08:59.
If you are using Visual Studio for building your project, why are you also using Qt Creator? Stick with one or the other. I use Visual Studio (only) along with the Qt VS plugin for all of my Qt projects. The only thing I use Qt Creator for is to build and run the demos that come with Qt, and that only because I don't want to be bothered creating a Visual Studio project for them.
Why are you putting LIB, DLL and EXE files into the VS project? What do you think Visual Studio (or Qt Creator for that matter) is going to do with them?
By the way, if you are using Visual Studio to build your own project, any LIBs or DLLs also have to be built by the Visual C++ compiler. If your Qt Creator kit is using mingw, anything compiled in Qt Creator will be incompatible with code built in VS.
Im using Qt creator to adjust my .pro file, because I can launch qmake there (And I think that it's necessary for applying changes in .pro file). I couldn't find it in Visual Studio.
I'm putting all files from the lua folder for 100% working. I will clean my project after it works.
I downloaded lua5.3.0.tar.gz, opened Visual Studio command prompt and made the files with proper commands. Anyway it works in console project.
I think the problem is in .pro file. I should link the lua library. How can I do it properly? (Maybe in Visual Studio, if it's possible)
Assuming your Lua deployment folder C:\Lua contains:
Then this does itQt Code:
Archive: lua-5.3_Win32_dll10_lib.zip Length Date Time Name --------- ---------- ----- ---- 8433 10-30-2014 02:11 include/lauxlib.h 14734 12-27-2014 03:24 include/lua.h 191 12-23-2004 10:53 include/lua.hpp 20308 05-19-2015 11:04 include/luaconf.h 1173 02-07-2014 03:32 include/lualib.h 231936 05-20-2015 00:47 lua53.dll 30044 05-20-2015 00:47 lua53.lib --------- ------- 306819 7 filesTo copy to clipboard, switch view to plain text mode
Qt Code:
TEMPLATE = app TARGET = test DEPENDPATH += . INCLUDEPATH += . INCLUDEPATH += C:/Lua/include LIBS += -LC:/Lua -llua53 # Input SOURCES += main.cppTo copy to clipboard, switch view to plain text modeQt Code:
#include <QCoreApplication> #include <lua.hpp> int main(int argc, char *argv[]) { lua_State* s = luaL_newstate(); luaopen_base(s); lua_pcall(s, 0, 0, 0); int result = a.exec(); lua_close(s); return result; }To copy to clipboard, switch view to plain text mode
I couldn't find where I can use .pro file in Visual Studio (It creates .pro file, but then no using it).
So I tried to do it with Qt Creator. Qt finds libraries,
Qt Code:
TEMPLATE = app TARGET = newluaQt DESTDIR = ../Win32/Debug QT += core widgets gui CONFIG += debug LIBS += -L"$$_PRO_FILE_PWD_/lua/" -llua5.3.0 DEFINES += WIN64 QT_DLL QT_WIDGETS_LIB INCLUDEPATH += ./GeneratedFiles \ . \ ./GeneratedFiles/Debug \ ./lua DEPENDPATH += . MOC_DIR += ./GeneratedFiles/debug OBJECTS_DIR += debug UI_DIR += ./GeneratedFiles RCC_DIR += ./GeneratedFiles include(newluaQt.pri)To copy to clipboard, switch view to plain text mode
How do i realise: I tried to launch with "-llua5.3" for example. And Qt said me "Can't find lua5.3 lib", then I tried "-llua5.3.0" and Qt said me again about my linker error. How can I fix it? I'm already trying to solve it by a couple of weeks
Qt does not issue any of these messages. Your linker issues these messages because it was invoked with insufficient information to allow it to find the library. Once qmake has created the Makefile to your specification Qt is not involved in the process of compilation/linking.And Qt said me "Can't find lua5.3 lib", then I tried "-llua5.3.0" and Qt said me again about my linker error.
We cannot see what your library file is called or where it lives. Look at my example, work out the quite obvious pattern, and do the equivalent in your pro file.
Is the name of your library file lua5.3.0.lib/lua5.3.0.dll? No, then adjust the pro file accordingly.
Do you even have a compiled library to work with? I simply downloaded the precompiled library zip file to generate my example.
Does your .lib file live in a directory called "lua" in the same place as the pro file? No, then adjust the pro file accordingly.
Does _PRO_FILE_PWD_ expand to the value you think it does? Try an absolute path instead.
Does newLuaQt.pri change any of these relevant variables?
Try understanding the actual generated compiler command that fails and how that relates to your pro file.
I've written exactly what I have in the message above:We cannot see what your library file is called or where it lives
Then I attached a screenshot when you can see that the names are lua5.3.0.lib and lua5.3.0.dll: http://www.qtcentre.org/attachment.p...1&d=1434354607What exactly I do now:
Create Qt project in Visual stuido. Change x32 to x64 and check if the project launches correctly.
After checking I add into the project folder (in the windows explorer) a new folder "lua" and put into this all necessary lua-files (lua .c, .h, one .hpp, .lib, .dll and .exe files). Then I create into solution explorer (in Visual Studio) a new folder "lua" and put (drag n drop) into this all files from the folder "lua" in the windows explorer.
Yes, I've written it here:Do you even have a compiled library to work with?
I downloaded lua5.3.0.tar.gz, opened Visual Studio command prompt and made the files with proper commands. Anyway it works in console project.
Yes, "I add into the project folder (in the windows explorer) [B]a new folder "lua" and put into this all necessary lua-files".Does your .lib file live in a directory called "lua" in the same place as the pro file?
The "project folder" I mean the directory of .pro file.
Everyone writes that it's directory of .pro file. I have tried both $$_PRO_FILE_PWD_ and $$PWD. Okay, I will try the absolute.Does _PRO_FILE_PWD_ expand to the value you think it does?
About .pri - Don't know. It's generated by Visual Studio
Bookmarks