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.
I solved this by moving my project to Ubuntu. Momentics for Windows doesn't work well with GNU C++ as runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With