Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BlackBerry 10: GNU STL

I am trying to create a BB10 cascades project with Momentics IDE version 2.0 and I need the project to use the GNU Standard library instead of Dinkumware (because I have external libs compiled with arm-unknown-nto-qnx8.0.0eabi-g++ that only supports gnu std).

In the IDE, I have changed Project Properties->C/C++ Build/Settings/Runtime to "C++ GNU with exceptions". However, when I run a simple project with a static library (.a file) created by me (with just a header file containing a constructor, std::string object, setter and getter (for the object) and the corresponding cpp file), I get a segmentation fault when I do this:

testnamespace::testclass *object = new testnamespace::testclass();

std::string test = "Hello";
object->setText(test);

delete object;

I think this error occurs because the library was compiled with gnu std and the project is compiled with Dinkumware.

I verified the include paths, and I found out that

C:\bbndk\target_10_1_0_428\qnx6\usr\include 

is included before

C:\bbndk\target_10_1_0_428\qnx6\usr\include\c++\4.6.3

Also, the command used by the makefile to compile the cpp files in the project is qcc -Vgcc_ntoarmv7le instead of qcc -V4.6.3,gcc_ntoarmv7le_gpp (support flag for gnu stl).

Am I doing something wrong? Some configuration is missing?

I really need to use GNU STD instead of Dinkumware in my BlackBerry project, but I can't figure out how to do it.

EDIT:

I have made some changes in my project and I fixed some issues.

I added this to my .pro file

QMAKE_CXX = qcc -V4.6.3,gcc_ntoarmv7le_gpp
QMAKE_CC = qcc -V4.6.3,gcc_ntoarmv7le
QMAKE_LINK = qcc -V4.6.3,gcc_ntoarmv7le_gpp
QMAKE_AS = qcc -V4.6.3,gcc_ntoarmv7le_gpp

LIBS += -lc -lm -lcpp -lstdc++ -Bstatic ../libs/libteste.a -Bdynamic

(LIBS command was already there of course, but I decided to put it here so you can understand how I am linking the libs).

Now, I have the following code:

testenamespace::TesteClass *temp = new testenamespace::TesteClass() ;

std::string teste = "Hello";

temp->setTesteString(teste);

QString qsr = QString::fromStdString(temp->getTesteString());


qDebug ("String in the object: "+qsr.toLatin1());

delete temp;

Everything works fine, until the code reaches delete temp; where I am getting the output:

Qml debugging is enabled. Only use this in a safe environment! String in the object: Hello Process 1173778674 (test_bb10) terminated SIGSEGV code=2 fltno=11 ip=0150ed7c(/usr/lib/ldqnx.so.2@_list_release+0x3c) mapaddr=0002ed7c. ref=78362e2b

and sometimes I get

Qml debugging is enabled. Only use this in a safe environment! String in the object: Hello free malloc object that is not allocated:../../dlist.c:1096**

I think that the problem is in new and delete invocations, maybe the standard library imported by the processor is not the right one.

Thanks in advance.

like image 259
Filipe Figueiredo Avatar asked Nov 02 '22 09:11

Filipe Figueiredo


1 Answers

I solved this by moving my project to Ubuntu. Momentics for Windows doesn't work well with GNU C++ as runtime.

like image 82
Filipe Figueiredo Avatar answered Nov 04 '22 12:11

Filipe Figueiredo