lua qt 编译,将Lua与Qt链接

本文介绍了如何解决在Qt Creator中集成Lua遇到的问题,包括错误的库文件路径和不兼容的架构问题。通过交叉编译Lua库以匹配目标平台,最终实现了Lua脚本在Qt Creator中的正确运行。

I am a noob so if what I am asking is straight forward, or something basic that I have missed, please excuse me.

Im trying to link Lua with Qt creator so that I can run a basic Lua script. I included all of the header files required by Lua in my main.cpp file. And low I'm trying to link the liblua.a library to the project; so what I did is, I manually added the library.

The Creator then generated this code, and added it to my .pro - file :

unix:!macx: LIBS += L$$PWD/ -llua

INCLUDEPATH += $$PWD/

DEPENDPATH += $$PWD/

unix:!macx: PRE_TARGETDEPS += $$PWD/liblua.a

Then when I start the debugger, I get two errors:

-Skipping incompatible /home/..path to Lua source files../liblua.a when searching for -llua

-cannot find -llua

I'm running Ubuntu 12.04, and the version of Lua that I'm currently working with is 5.2.3

Can someone please advise me as to what I am doing wrong?

EDIT:

Compile Output:

16:48:10: Running steps for project testApp...

16:48:10: Configuration unchanged, skipping qmake step.

16:48:10: Starting: "/usr/bin/make"

arm-linux-gnueabihf-g++ -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.8.4-arm/lib -o

testApp main.o -L/usr/local/Trolltech/QtEmbedded-4.8.4-arm/lib -ldl -L/home/david

/workspace/testApp/ -llua -lQtNetwork -L/usr/local/Trolltech/QtEmbedded-4.8.4-

arm/lib -lQtCore -lpthread

/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/bin/ld:

skipping incompatible /home/david/workspace/testApp//liblua.a when searching for

-llua

/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/bin/ld: cannot

find -llua

collect2: ld returned 1 exit status

make: *** [testApp] Error 1

16:48:10: The process "/usr/bin/make" exited with code 2.

Error while building/deploying project testApp (kit: SAP)

When executing step 'Make'

16:48:10: Elapsed time: 00:00.

解决方案

Finally, I got it solved!

The problem was that that I had to cross compile the Lua library for the ARM core. The architecture of the original Lua library was not recognizable by the core, as the execution of the program took place on the core itself when debugging.

I did this by :

$ make linux CC=PATH/arm-linux-gnueabihf-gcc AR=”PATH/arm-linux-gnueabihf-ar rcu” RANLIB=PATH/arm-linux-gnueabihf-ranlib

and removing all references to readline in the makefile and config file before executing above command.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值