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
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Porting Libraries - id3

[ Edited ]

Library Name: id3

id3v2.gif 


Library Home Page: http://id3lib.sourceforge.net/

 

Library platform: C/C++

 

Build Environment Used: Linux

 

Build System: Autotools

 

Description:

From the id3lib home page, "id3lib is an open-source, cross-platform software development library for reading, writing, and manipulating ID3v1 and ID3v2 tags.". In short, it allows you to read and update the MP3 meta data or "tags" contained within MP3 format music files.


Version Ported: 3.8.3

 

Tested on BlackBerry: 10.2.0


Where can I find the original source for this library?

 

http://sourceforge.net/projects/id3lib/files/id3lib/3.8.3/

 

 

Summary of Porting Procedure

1. Download the source distribution
2. Unpack to your development machine
3. Acquire and apply patch
4. Set environment variables
5. Build
6. Check library attributes
7. Test library

 

Detailed Procedure


Step 1: Download the standard source distribution: http://sourceforge.net/projects/id3lib/files/id3lib/3.8.3/id3lib-3.8.3.tar.gz/download

 

Step 2: Unpack

 

gunzip id3lib-3.8.3.tar.gz
tar xvf id3lib-3.8.3.tar

 

Step 3: Download the following patch into the id3lib source folder:

 

http://connie.slackware.com/~alien/slackbuilds/id3lib/build/id3lib-3.8.3_gcc4.diff

 

Step 4: Patch the source

 

patch -p1 < id3lib-3.8.3_gcc4.diff

 


Step 5: Set the NDK environment variables

 

cd <ndk installation location>
. ./bbndk-env_10_2_0_1155.sh

 

Step 6: Building the library

 

For ARM (BlackBerry 10 device):

 

CXX="qcc -Vgcc_ntoarmv7le -lang-c++ -fPIC" CC="qcc -Vgcc_ntoarmv7le -fPIC" ./configure --host=arm-unknown-nto-qnx8.0.0eabi --prefix=`pwd`/build/arm-qnx AR=arm-unknown-nto-qnx8.0.0eabi-ar

 

For x86 (BlackBerry 10 simulator):

 

CXX="qcc -Vgcc_ntox86_cpp -lang-c++" CC="qcc -Vgcc_ntox86_cpp" ./configure --host=i486-pc-nto-qnx8.0.0 --prefix=`pwd`/build/x86-qnx

 

Note that we set additional environment variables CXX and CC to ensure that the QNX compiler is used rather than some other compiler the build machine may happen to have installed (g++ for example).

 

Notes on arguments:

--prefix sets the location for the output when running make install: http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Default-Prefix.html

 

--host=arm-unknown-nto-qnx8.0.0eabi

 

--host specifies the type of system on which the package runs. Causes some AC_ macros to prefix the name of the program being checked for with the specified host identifier. For example AC_CHECK_TOOL([RANLIB], [ranlib], [:])would set RANLIB to iarm-unknown-nto-qnx8.0.0eabi-ranlib in our case

 

About "arm-unknown-nto-qnx8.0.0eabi":
EABI stands for Embedded Application Binary Interface. See http://en.wikipedia.org/wiki/Application_binary_interface

 

This is the value to use when cross compiling for a BlackBerry 10 device
Maps to binaries in <ndk location>\host_10_2_0_15\linux\x86\usr\bin

AR=arm-unknown-nto-qnx8.0.0eabi-ar

 

This explicitly sets the command to use for creating an archive. Usually this isn't required, however, it may be necessary for id3lib to stop the configure script from attempting to use the default ar command which would result in a malformed library during the "make install" phase of building the library.

 

make -j2

 

 

# -j2 indicates that both my machine's CPUs should be used

 

# Expect compilation errors the first time you run make. In the case of id3, all errors were caused by the fact that the qcc compiler has stricter rules about name spaces and therefore it was necessary to prefix calls to various functions with std::

# These are the functions that needed explicit name space prefixes:
#
# strcat
# strlen
# strcmp
# strcpy
# strncmp
# memcmp
# memcpy
# memset
# memmove
# isdigit

 

make install

 

 

# Your static library will be called libid3.a and you'll find it in `pwd`/build/arm-qnx/lib

 

Step 7: Checking your library

 

cd build/arm-qnx/lib

ntoarm-readelf -h libid3.a 

 

Check that Machine: reads "ARM"


ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data&colon; 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 22948 (bytes into file)
Flags: 0x5000000, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 30
Section header string table index: 27


Step 8: Testing the library


Create a folder testid3 at the same level as your id3lib folder.

 

mkdir testid3

 

Create a single file main.cpp with the following contents:

 

#include <id3/tag.h>
int main()
{
std::cout << "Hello ID3\n"; //Just changed the output to standard C++ convention rather than C
ID3_Tag myTag();
}

 

To compile the test file you'll need to do the following:

 

For ARM:

 

testid3$ arm-unknown-nto-qnx8.0.0eabi-g++ -L../id3lib-3.8.3/build/arm-qnx/lib -lid3 -I../id3lib-3.8.3/build/arm-qnx/include main.cpp -o mainarm

 

For x86:

 

testid3$ i486-pc-nto-qnx8.0.0-g++ -L../id3lib-3.8.3/build/x86-qnx/lib -lid3 -I../id3lib-3.8.3/build/x86-qnx/include main.cpp -o mainx86

 

Note that a BlackBerry 10 sample application which uses the ported id3 library will be released to the GitHub Cascades-Community-Samples repository when possible. Watch this space for updates. 

 


Possible Problems


P1. configure fails with:

 

checking for iomanip.h... no
configure: error: Missing a vital header file for id3lib

 

Solution:

 

Acquire and apply the patch mentioned in step 3 above.

 

Make sure you specify the CXX and CC environment variables in your call to ./configure like this:

 

CXX="qcc -Vgcc_ntoarmv7le -lang-c++" CC="qcc -Vgcc_ntoarmv7le" ./configure --host=arm-unknown-nto-qnx8.0.0eabi --prefix=`pwd`/build/arm-qnx AR=arm-unknown-nto-qnx8.0.0eabi-ar


P2. "Malformed archive" is reported when you run make install

 

The archiver (ar) command is incorrectly set in the configure script.

 

This causes the libid3.a static library (an archive) to be created incorrectly.

 

The first sign of this error is during "make install" when "Malformed archive" is displayed.

 

Solution:

 

Supply the full ar command name as a linker flag to configure.

 

./configure --host=arm-unknown-nto-qnx8.0.0eabi --prefix=`pwd`/build/arm-qnx AR=arm-unknown-nto-qnx8.0.0eabi-ar

P3. readelf output indicates that the resultant library is not for ARM machines. E.g.

 

File: libid3.a(writers.o)
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data&colon; 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 20408 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 27
Section header string table index: 24

 

Solution:

 

This suggests you did not set environment variables that establish the QNX tool chain in the environment such that the configure script finds and utilises its binaries.

 

Run <ndk installation>/bbndk-env_10_2_0_1155.sh and try again starting with "make clean". Make sure environment variables get set in the current shell not a child shell but starting your command with ". " like this:

 

cd <ndk installation>

. /bbndk-env_10_2_0_1155.sh

 

P4. For some reason you are not certain that the BlackBerry 10/QNX compiler is being used

Solution:


Open config.log and check for lines like these, which indicate the right version of gcc is being used:

 

configure:1939: checking for arm-unknown-nto-qnx8.0.0eabi-gcc
configure:1955: found /home/martin/bbndk/host_10_2_0_15/linux/x86/usr/bin/arm-unknown-nto-qnx8.0.0eabi-gcc
configure:1965: result: arm-unknown-nto-qnx8.0.0eabi-gcc

 

P5. SIGSEGV code=1 fltno=11 ip=7994bf7c(/proc/boot/libcpp.so.4@_ZNKSt6locale9_GetfacetEj+0x27) mapaddr=0002bf7c. ref=00000010"

 

Concerns this function:

 

$ nm -g -C libcpp.so |grep Getfa
0002bf55 T std::locale::_Getfacet(unsigned int) const

 

Solution:

 

Make sure you include -lcpp in your project's .pro file. libcpp contains the Getfacet function.

 

P6. Link does not parse mp3 file; no frames found

 

Check your file using one of the example apps "id3info", running on Linux e.g.

 

martin@psyduck:~/tmp/id3lib-3.8.3/examples$ ./id3info
martin@psyduck:~/tmp/id3lib-3.8.3/examples$ ./id3info Pursuit\ of\ Unhappiness\ Edit.mp3
*** Tag information for Pursuit of Unhappiness Edit.mp3
=== TT2 (Title/songname/content description): Pursuit of Unhappiness
=== TP1 (Lead performer(s)/Soloist(s)): Martin Woolley
=== TAL (Album/Movie/Show title): No album
=== TYE (Year): 2007
=== TCO (Content type): Electronic Rock
*** mp3 info
MPEG1/layer III
Bitrate: 256KBps
Frequency: 44KHz

 

If you get output like this, then the file is OK and there must be something wrong with the ported version.


Resources

Autoconf Manual - http://www.gnu.org/software/autoconf/manual/autoconf.html

 

Example application using id3 library:

 

https://github.com/blackberry/Cascades-Community-Samples/tree/master/ID3TestApp

 

IMG_00000005.png

 

IMG_00000006.png

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
New Contributor
fmunozs
Posts: 5
Registered: ‎01-09-2013
My Device: BB10 Alpha B

Re: Porting Libraries - id3

Thanks for this post, I was trying to download the ID3TestApp to see how is the packaging / bar-descriptor, but seems that the link is broken, could you check? 

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Porting Libraries - id3

Sorry, there's been a delay and Id3TestApp has not yet been released (in our internal review process). I'll update the original post so that this is clear.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: Porting Libraries - id3

Is there a version where the library is already compiled? I do not see it in the sample app.

 

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Porting Libraries - id3

No, sorry we're not allowed to distribute binaries as it may complicate the licence legalities.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: Porting Libraries - id3

so I can compile the lib with bb10 sdk or do i need to install another sdk?

 

 

 

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Porting Libraries - id3

You can build it with the BB10 SDK but you need to follow the instructions in this article. Basically you're using the SDK from the command line to cross-compile to QNX.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
AricLam
Posts: 28
Registered: ‎11-07-2013
My Device: 9790

Re: Porting Libraries - id3

I can't build a library id3tag. pls help me.