PDA

View Full Version : Importing LUA into Qt Creator project on Windows linking problem



MarkoSan
10th February 2011, 15:40
Hi to all!

I am trying to compile qt 4.7.0 app that integrades LUA scripting language in Qt Creator 2.0.1 under Windows 7 Ultimate. At compile time, I get following errors:
debug/mainwindow.o:C:\Users\HP2\Desktop\ABTeamTestApp-build-desktop/../ABTeamTestAppWC/mainwindow.cpp:32: undefined reference to `luaL_newstate' debug/mainwindow.o:C:\Users\HP2\Desktop\ABTeamTestApp-build-desktop/../ABTeamTestAppWC/mainwindow.cpp:35: undefined reference to `luaL_openlibs'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\ABTeamTestApp.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project ABTeamTestApp (target: Desktop)
When executing build step 'Make'
When executing build step 'Make'.Now, the reason for error is following method:
void MainWindow::initLUA()

{

lua_State* L=lua_open();

if(!L)

qFatal("LUA cannot be initialized.");

luaL_openlibs(L);

}I am checking my .pro file (for including dlls and libs)
and I am getting nowhere. Here is .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2011-02-10T10:21:14
#
#-------------------------------------------------

QT += core gui

TARGET = ABTeamTestApp
TEMPLATE = app
CONFIG += ordered

SOURCES += main.cpp\
mainwindow.cpp \
centralwidget.cpp \

HEADERS += mainwindow.h \
centralwidget.h \
lua/include/lualib.h \
lua/include/luaconf.h \
lua/include/lua.hpp \
lua/include/lua.h \
lua/include/lauxlib.h

win32:LIBS += \
-L"lua/lib/lua5.1.lib" \
-L"lua/lib/lua51.lib" \
-L"lua/lib/lua5.1.dll" \
-L"lua/lib/lua51.dll"Can someone help me with problem?

Sincerely,
Marko

stampede
10th February 2011, 16:07
win32:LIBS += \
-L"lua/lib/lua5.1.lib" \
-L"lua/lib/lua51.lib" \
-L"lua/lib/lua5.1.dll" \
-L"lua/lib/lua51.dll"
Use '-L' switch to define a directory to search for libraries, you need to use '-l' if you want to link a library.
And whats the point in dynamic and static linking at the same time ?
Use .dlls or .libs ( you link to .dll with -l )

win32:LIBS += \
-L"lua/lib" \
-llua5.1
or

[CODE]win32:LIBS += "lua/lib/lua5.1.lib"

MarkoSan
10th February 2011, 17:03
Thanks! It compiles now! I am little tired and I did not see it :D

Added after 51 minutes:

Well, now I have same god damn problem under Mac OS X, how do I redefine LIBS section for mac?