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
Contributor
helixion
Posts: 17
Registered: ‎03-28-2012
My Device: Developing on multiple models
My Carrier: Multiple providers

Undefined reference - link error

[ Edited ]

Hi,

 

I have a problem in linking my libraries with a cascades project. I have ocut it down to a minimal and tries to give a picture of what I am doing below:

 

Blackberry static library - to act as an interface for several Secure Elements

interface-project

      |_src

            |_includes

            |      |_NFCInterface.hpp

            |_cpps

                   |_NFCInterface.cpp

 

NFCInterface.hpp

#ifndef NFC_INTERFACE_HPP_
#define NFC_INTERFACE_HPP_
class NFCInterface {
public:
NFCInterface();
virtual ~NFCInterface();
};
#endif /* NFC_INTERFACE_HPP_ */

 NFCInterface.cpp

#include "../includes/NFCInterface.hpp"

NFCInterface::NFCInterface() {
}

NFCInterface::~NFCInterface() {
}

 Above project compiles without any problem.

 

Blackberry static library - An implementation for UICC

interface-project-impl

      |_src

            |_includes

            |      |_NFCInterfaceImpl.hpp

            |_cpps

                   |_NFCInterfaceImpl.cpp

 NFCInterfaceImpl.hpp

#ifndef NFC_INTERFACE_IMPL_
#define NFC_INTERFACE_IMPL_
#include <NFCInterface.h>

class NFCInterfaceImpl:public NFCInterface {
public:
	NFCInterfaceImpl();
	virtual ~NFCInterfaceImpl();
};

#endif /* NFC_INTERFACE_IMPL_ */

 NFCInterfaceImpl.cpp

#include "../includes/NFCInterfaceImpl.h"

NFCInterfaceImpl::NFCInterfaceImpl() {
	// TODO Auto-generated constructor stub

}

NFCInterfaceImpl::~NFCInterfaceImpl() {
	// TODO Auto-generated destructor stub
}

The above project with -I <project location>/src/includes -L<Library location> -lnfcinterface compiles without any problem.

 

Blackberry cascades project - the acutal front end

test-project

      |_src

            |_main.cpp

            |_TestLib.cpp

            |_TestLib.hpp

 

TestLib.hpp

// Tabbed pane project template
#ifndef TestLib_HPP_
#define TestLib_HPP_

#include <QObject>

namespace bb { namespace cascades { class Application; }}

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class TestLib : public QObject
{
    Q_OBJECT
public:
    TestLib(bb::cascades::Application *app);
    virtual ~TestLib() {}
};

#endif /* TestLib_HPP_ */

 TestLib.cpp

// Tabbed pane project template
#include "TestLib.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include "NFCInterfaceImpl.h"

using namespace bb::cascades;

TestLib::TestLib(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
    NFCInterfaceImpl test;
}

 

Now in the above project, in the pro file I have 

 

INCLUDEPATH +=  \
    ../NFCInterface/src/includes \
    ../NFCInterfaceImpl/src/includes

LIBS += \
    -LC:/Users/myuseraccount/ndk-10.0.9-workspace/NFCInterface/Device-Debug \
    -LC:/Users/myuseraccount/ndk-10.0.9-workspace/NFCInterfaceImpl/Device-Debug \
    -lnfcinterface \
    -lnfcinterfaceimpl

 If I compile I get the following error:

Could not find qmake configuration directoryCould not find qmake configuration fileUsing OS scope before setting MAKEFILE_GENERATORC:/Users/myaccountname/ndk-10.0.9-workspace/NFCInterfaceImpl/Device-Debug\libNFCInterfaceImpl.a(NFCInterfaceImpl.o): In function `NFCInterfaceImpl':
make[2]: Leaving directory `C:/Users/myaccountname/ndk-10.0.9-workspace/test-lib/arm'
C:\Users\myaccountname\ndk-10.0.9-workspace\NFCInterfaceImpl\Device-Debug/..\src\cpps/NFCInterfaceImpl.cpp:10: undefined reference to `NFCInterface::NFCInterface()'
make[1]: Leaving directory `C:/Users/myaccountname/ndk-10.0.9-workspace/test-lib/arm'
C:/Users/myaccountname/ndk-10.0.9-workspace/NFCInterfaceImpl/Device-Debug\libNFCInterfaceImpl.a(NFCInterfaceImpl.o): In function `~NFCInterfaceImpl':
C:\Users\myaccountname\ndk-10.0.9-workspace\NFCInterfaceImpl\Device-Debug/..\src\cpps/NFCInterfaceImpl.cpp:17: undefined reference to `NFCInterface::~NFCInterface()'
cc: C:/Users/myaccountname/Applications/bbndk/host_10_0_9_404/win32/x86/usr/bin/ntoarm-ld caught signal 1
make[2]: *** [o.le-v7-g/test_lib] Error 1
make[1]: *** [debug] Error 2
make: *** [Device-Debug] Error 2

Could not figure out what's wrong. Is this the correct way to implement libraries (with the cascades)? I know I am missing something basic. If anybody can figure out, please point out.

 

Please let me know if you need more information in this regard.

 

Thanks

 

Please use plain text.
Developer
Developer
CMY
Posts: 1,122
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Undefined reference - link error

I don't know if this is the issue, but I know on *nix platforms, everything is case sensitive and your library names are all lowercase in the link statements but in the output it has capitals in it. I would make sure that the names match exactly first.
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Undefined reference - link error

Doe it compile successfully if you remove your additions to .pro file?

Please use plain text.
Contributor
helixion
Posts: 17
Registered: ‎03-28-2012
My Device: Developing on multiple models
My Carrier: Multiple providers

Re: Undefined reference - link error

Thanks CMY. Though I compile it on Windows, I take your point as it looks like a cygwin involvement. However, even after changing the case, it is still the same.

 

Cheers

Please use plain text.
Contributor
helixion
Posts: 17
Registered: ‎03-28-2012
My Device: Developing on multiple models
My Carrier: Multiple providers

Re: Undefined reference - link error

Thanks BGmot. It does not work if remove them.

Cheers
Please use plain text.
Developer
Developer
CMY
Posts: 1,122
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Undefined reference - link error

Can you post your make files?
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Undefined reference - link error

Another thing to consider: you make nfcinterfaceimpl wih statically linked nfcinterface library, i.e. impl binary already contains all the code from nfcinterface. Then you are trying to build your app with static linking of both libraries, this way in your final binary you'll have two instances of nfcinterface library. I am not sure how well linker handles that. Also it would be nice to see all console output when you build your final app.

Please use plain text.