I am currently working on building a Cocos2d-x game for the BB10 platform using the BBTemplateProject sample provided with Cocos2dx. I am new to C++ programming, and the current game is a port of a java project Iv been working on for a while. In order to save game data (scores, some settings etc), I intend to use the QtSQl Library which BB10 provides. I have successfully run some sample Qtsql code in a sample Cascades application and it works fine. However, integrating the same code into my Cocos2dx BB10 project just doesnt work . I use the momentics IDE and have added the qt4, QtCore, QtDeclarative, paths/symbols to the project but still recieve the following errors
undefined reference to `QObject::QObject(QObject*)'
undefined reference to `vtable
undefined reference to `QSqlDatabase::defaultConnection'
.. and a bunch of other Q- related object errors.
After reading up on Qobject here http://developer.blackberry.com/cascades/reference/moc.html I suspect that the MOC compiler is not appropriating referenced or a similar issue. Also, given the same code works well when integrated in an auto generated cascades project in the Momentics IDE, I am led to believe it is some sort of moc compiler issue. Given that I am quite new to C++ development, I still havent been able to figure out how to add the appropriate qmake file rules to the Momentics IDE in order to recognise Qobjects . Help is needed in this area.
Will definitely appreciate any pointers on how to go about this from experienced c++ devs or better ways to store data within cocos2dx blackberry 10 projects.
Thanks in advance.
Edit :
Here's , my progress thus far in trying to use QtSql for database interaction. QtSQl requires QtCore which contains QObject above. Thus far I have been unable to successfully integrate QtCore library.
I have done the following.
Added the /usr/include/qt4 and /usr/include/QtCore and /usr/include/QtSql to my include list using the following procedure
Right click over your project in Project Explorer and choose Properties
- Expand the tree to C/C++ General / Paths and Symbols
- Change the Configuration in the Paths and Symbols frame to [All configurations]
- Click the Includes tag and select GNU C in the Languages list (or do this for every language).
- Click Add... and type ${QNX_TARGET}/usr/include/qt4 and press OK
Click Add... and type ${QNX_TARGET}/usr/include/qt4/QtCore and press OK
Used the Momentics IDE add library function to add both QtCore and QtSql to the project. RightClick->configure->add Library and Standard BlackBerry Platform Library. The library gets added successfully.
I basically followed the steps detailed in this related post Adding QtCore Library in blackberry 10 sdk . But now get this error.
\win32\x86\usr\bin\ntoarm-ld: cannot find -lQtCore
The OP in that post mentions solving "some linker problems" but fails to mention how. I have also tried modifying the bar-descriptor.xml file adding the following lines
<env var="LD_LIBRARY_PATH" value="app/native/lib:/usr/lib/qt4/lib"/>
<asset path="${QNX_TARGET}\${CPUVARDIR}usr\lib\qt4\lib\libQtCore.so" type="Qnx/Elf">lib/libQtCore.so.4</asset>
Error still remains. How do I solve this "linker" or library-no-found error ? Many Thanks.