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
Posts: 579
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA
Accepted Solution

Using the XMP library

I was interesting in trying out the XMP library, so it was nice to see that it was included here:

 

https://developer.blackberry.com/native/documentation/core/library_support_at_a_glance.html

 

... with instructions on how to add a library here:

 

https://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/topic/add...

 

However, I'm not sure how to include the .hpp files into my project.

 

The sample code I've found from the XMP SDK does something like this:

 

#include <cstdio>
#include <vector>
#include <string>
#include <cstring>

// Must be defined to instantiate template classes
#define TXMP_STRING_TYPE std::string

// Must be defined to give access to XMPFiles
#define XMP_INCLUDE_XMPFILES 1

// Ensure XMP templates are instantiated
#include "public/include/XMP.incl_cpp"

// Provide access to the API
#include "public/include/XMP.hpp"

#include <iostream>
#include <fstream>

using namespace std;

 

... they key part seemingly being:

 

// Ensure XMP templates are instantiated
#include "public/include/XMP.incl_cpp"

// Provide access to the API
#include "public/include/XMP.hpp"

 

When I examine the "Includes" node of my project, I do see a line pointing to:

 

E:\bbndkbeta\target_10_2_0_1155\qnx6\usr\include\xmp

 

... and it does include both XML.incl_cpp and XMP.hpp, but when I add those two includes:

 

#include "xmp/XMP.incl_cpp"
#include "xmp/XMP.hpp"

 

... into my .hpp file and build, I get all sorts of errors such as:

 

o.le-v7-g/.obj/PhotosModel.o: In function `.LC333':
PhotosModel.cpp:smileysad:.rodata+0x2a98): multiple definition of `typeinfo for TXMPFiles<std::string>'
o.le-v7-g/.obj/ImageViewContainer.o:ImageViewContainer.cpp:smileysad:.rodata+0x4fc): first defined here

 

Here's the exact code I adapted from the sample code for my header file:

 

#include <cstdio>
#include <vector>
#include <string>
#include <cstring>

// Must be defined to instantiate template classes
#define TXMP_STRING_TYPE std::string

// Must be defined to give access to XMPFiles
#define XMP_INCLUDE_XMPFILES 1

#define UNIX_ENV 1

#include "xmp/XMP.incl_cpp"
#include "xmp/XMP.hpp"

#include <iostream>
#include <fstream>

using namespace std;

 

Thanks,
Daniel

 

 

Developer
Posts: 579
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Using the XMP library

Not sure if this is a clue, but if I move the XMP stuff from my .hpp into my main.cpp file, it works, without any of those errors.

 

... which is great, but I need to write XMP code in my .hpp file, and not limit it to my main.cpp file.

Developer
Posts: 579
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Using the XMP library

Ok.  I've stumbled upon the answer, I think.

 

It appears that the inclusion of:

 

/#include "xmp/XMP.incl_cpp"

 

... needs to be limited to main.cpp, and should not be placed into other .hpp files. Rather, you just:

 

#include "xmp/XMP.hpp"

 

... in any .hpp file you need XMP. I suppose that makes sense...