Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

Build error associated with a class - why?

I have a class I am trying to create that I can use in any application as a utility class to invoke the Browser. 

 

However when I add this class to an application - any application including HelloCascades - the build fails.

 

Comparing the console logs I see this at the end of a good build (without this class)

 

"
qcc -Vgcc_ntox86 -lang-c++ -Wl,-rpath-link,C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/lib -Wl,-rpath-link,C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib -o o-g/hellocascades o-g/.obj/hellocascadesapp.o o-g/.obj/main.o o-g/.obj/moc_hellocascadesapp.o    -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib/qt4/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6//usr/lib/qt4/lib -lbb -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtXml -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
make[2]: Leaving directory `D:/Downloads/BB10/Samples/Cascades-Samples-master/hellocascades/x86'
make[1]: Leaving directory `D:/Downloads/BB10/Samples/Cascades-Samples-master/hellocascades/x86'
Could not find qmake configuration directoryCould not find qmake configuration fileUsing OS scope before setting MAKEFILE_GENERATOR

"

 

But I see the following at the end of the build that fails:

 

"

qcc -Vgcc_ntox86 -c -Wno-psabi -lang-c++ -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_LIB -DQT_SCRIPT_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/share/qt4/mkspecs/unsupported/blackberry-x86-qcc -I../../hellocascades -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtCore -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtNetwork -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtGui -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtXml -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtXmlPatterns -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtSql -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtSvg -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtScript -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4 -I../src -Io-g/.moc -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include -Ic:/bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/freetype2 -I. -o o-g/.obj/hellocascadesapp.o ../src/hellocascadesapp.cpp
qcc -Vgcc_ntox86 -lang-c++ -Wl,-rpath-link,C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/lib -Wl,-rpath-link,C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib -o o-g/hellocascades o-g/.obj/hellocascadesapp.o o-g/.obj/invokeBrowser.o o-g/.obj/main.o o-g/.obj/moc_hellocascadesapp.o o-g/.obj/moc_invokeBrowser.o    -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib/qt4/lib -LC:/bbndkbeta4/target_10_0_9_1101/qnx6//usr/lib/qt4/lib -lbb -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtXml -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
Could not find qmake configuration directoryCould not find qmake configuration fileUsing OS scope before setting MAKEFILE_GENERATORC:\bbndkbeta4\host_10_0_9_284\win32\x86\usr\bin\ntox86-ld: o-g/.obj/invokeBrowser.o: undefined reference to symbol '_ZN2bb6system13InvokeRequest11setMimeTypeERK7QString'
make[2]: Leaving directory `D:/Downloads/BB10/Samples/Cascades-Samples-master/hellocascades/x86'
make[1]: Leaving directory `D:/Downloads/BB10/Samples/Cascades-Samples-master/hellocascades/x86'
C:\bbndkbeta4\host_10_0_9_284\win32\x86\usr\bin\ntox86-ld: note: '_ZN2bb6system13InvokeRequest11setMimeTypeERK7QString' is defined in DSO C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib/libbbsystem.so.1 so try adding it to the linker command line
C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib/libbbsystem.so.1: could not read symbols: Invalid operation
cc: C:/bbndkbeta4/host_10_0_9_284/win32/x86/usr/bin/ntox86-ld caught signal 1
make[2]: *** [o-g/hellocascades] Error 1
make[1]: *** [debug] Error 2
make: *** [Simulator-Debug] Error 2

"

 

I am building to debug on the Simulator.  I have tried device builds and these fail too.  I have also tried Beta 3 and Beta 4. 

If you look hard you will see in the Console log this:

ZN2bb6system13InvokeRequest11setMimeTypeERK7QString

Now if I comment out the line setting the Mime type, this then changes to complaining about

_ZN2bb6system13InvokeRequest6setUriERK7QString

 

Apologies in advance for the code.  It probably seems like over kill, and I'm sure that the code I have created is bad c++, since in reality, I am a Java programmer learning C++.  But that said, I'd still like t understand why this class causes the build error.

 

TIA

 

/*
 * InvokeBrowser.h
 *
 *  Created on: 30 Nov 2012
 *      Author: ps
 */

#ifndef INVOKEBROWSER_H_
#define INVOKEBROWSER_H_

#include <bb/system/InvokeManager>
#include <bb/system/InvokeReply>
#include <bb/system/InvokeRequest>
#include <bb/cascades/Container>
#include <QObject>

class InvokeBrowser : public QObject {

	  Q_OBJECT

public:
	InvokeBrowser(bb::cascades::Container *parent = 0);
	virtual ~InvokeBrowser();

    void launchBrowser(QString);

private:
    void processInvokeReply();
    void showToast(const QString );

    bb::system::InvokeManager* _invokeManager;
	bb::system::InvokeReply * _invokeReply;
	bb::system::InvokeRequest * _request;
};

#endif /* INVOKEBROWSER_H_ */

 

/*
 * InvokeBrowser.cpp
 *
 *  Created on: 30 Nov 2012
 *      Author: ps
 */

#include "InvokeBrowser.h"

#include <bb/cascades/Container>

#include <bb/system/InvokeAction>
#include <bb/system/InvokeQueryTargetsReply>
#include <bb/system/InvokeQueryTargetsRequest>
#include <bb/system/InvokeReply>
#include <bb/system/InvokeRequest>
#include <bb/system/InvokeTarget>
#include <bb/system/InvokeTargetReply>
#include <bb/system/SystemToast>


InvokeBrowser::InvokeBrowser(bb::cascades::Container *parent)
	: QObject(parent)  {
}

InvokeBrowser::~InvokeBrowser() {
	// TODO Auto-generated destructor stub
	if ( ! _invokeManager ) {
		delete _invokeManager;
		_invokeManager = 0;
	}
	if ( _request ) {
		delete _request;
		_request = 0;
    }
}

void InvokeBrowser::launchBrowser(const QString URL) {

	// Create a new invocation request
	_request = new bb::system::InvokeRequest();
	_request->setAction(QLatin1String("bb.action.OPEN"));
	_request->setMimeType(QLatin1String("text/html"));
	_request->setUri(URL);

	// Start the invocation
	_invokeManager = new bb::system::InvokeManager();
	_invokeReply = _invokeManager->invoke(*_request);

	if (_invokeReply) {
		// Ensure that processInvokeReply() is called when the invocation has finished
		connect(_invokeReply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
	} else {
		showToast("Error starting browser");
		return;
	}

}

void InvokeBrowser::processInvokeReply() {

	if ( !_invokeReply ) {
    	return;
    }
	// Check for errors during invocation
    switch (_invokeReply->error()) {
        case bb::system::InvokeReplyError::BadRequest:
        	showToast("[ErrorBadRequest] Invoke Failed!");
            break;
        case bb::system::InvokeReplyError::Internal:
        	showToast("[ErrorInternal] Invoke Failed!");
            break;
        case bb::system::InvokeReplyError::NoTarget:
        	showToast("[ErrorNoTarget] Invoke Failed!");
            break;
        case bb::system::InvokeReplyError::TargetNotOwned:
        	showToast("[ErrorTargetNotOwned] Invoke Failed.");
            break;
        default:
            break;
    }
    // Delete the reply later on
    _invokeReply->deleteLater();
    _invokeReply = 0;

}

void InvokeBrowser::showToast(const QString toastString) {
	qDebug()<<"Toast: " + toastString;

	bb::system::SystemToast *toast = new bb::system::SystemToast();
	toast->setBody(toastString);
	toast->show();

}

 

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: Build error associated with a class - why?

try adding bbsystem library to linker's libraries list

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: Build error associated with a class - why?

Thanks.

 

This seems to be working, I am getting a compilation.  But I have found a few other problems so can't confirm this is working OK - will review in the morning.

 

For the next person, following the advice of the wizard, I updated my project's *.pro file replacing the line:

INCLUDEPATH += ../src

with

INCLUDEPATH += ../src ${QNX_TARGET}/usr/include/bb/system
DEPENDPATH += ../src ${QNX_TARGET}/usr/include/bb/system
LIBS += -lbbsystem

 

Looking at the invokeclient.pro file, I see:

LIBS += -lbbsystem -lscreen -lbbdata

 

Given this I suspect the only change I really needed to make was to add:

LIBS += -lbbsystem

 

Anyway, thanks again, will update when I have confirmed this has resolved the problem. 

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: Build error associated with a class - why?

Sorted my other issues, tested and working 100%.  Thanks again....

Please use plain text.
Contributor
jkurtw
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator

Re: Build error associated with a class - why?

Thanks for the clarity. I was about to go crazy with the same problem after including the clipboard functions in my project.

Turns out they tell you at the top level of the Utilities API:
https://developer.blackberry.com/cascades/reference/platform_utility.html

Please use plain text.