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
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

newb problem

hi gang,
newb problem. trying to compile an app in Momentics using NDK, C app and the libbtapi for Bluetooth.
I'm getting errors for "undefined reference to 'bt_device_init' and other calls. i'm not sure why. i admit i'm pretty new to C development, but this seems pretty straight forward.

I have a single main.c file, one function (a callback to handle events), and the main() which just tries to initialize the BT stack, then deinitialize it and exit.

here's the code:

/*
* main.c
*
* Created on: Oct 25, 2012
* Author: user
*/

#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <errno.h>
#include <btapi/btdevice.h>

/* this is a call back to handle BT_EVT events */

void bt_device_callback(const int event, const char *bt_addr, const char *event_data)
{
/* handle events */
fprintf(stderr, "Something happened!\n");
fprintf(stderr, "Event=%d\n", event);
return;
}

/* main program routine */

int main(int argc, char *argv[])
{
/* initialize the libbtapi library */

int btinit = bt_device_init(bt_device_callback);
if (btinit == 0) {
fprintf(stderr, "awesome: bt_device_init=%d\n", btinit);
} else {
fprintf(stderr, "not so awesome: bt_device_init=%d, errno=%d\n", btinit, errno);
}


/* de-initialize the libbtapi and shutdown */

bt_device_deinit();
return 0;
}

Here's the errors:

**** Build of configuration Simulator-Debug for project btoo ****

**** Internal Builder is used for build ****
qcc -o src\main.o ..\src\main.c -V4.6.3,gcc_ntox86 -w1 -IC:/Users/user/Downloads/bbndk/target_10_0_9_386/qnx6/usr/include/freetype2 -IC:/Users/user/Downloads/bbndk/target_10_0_9_386/qnx6/../target-override/usr/include -D_FORTIFY_SOURCE=2 -c -O0 -g -fstack-protector-all
qcc -o btoo src\main.o -V4.6.3,gcc_ntox86 -w1 -g -Wl,-z,relro -Wl,-z,now -LC:/Users/user/Downloads/bbndk/target_10_0_9_386/qnx6/../target-override/x86/lib -LC:/Users/user/Downloads/bbndk/target_10_0_9_386/qnx6/../target-override/x86/usr/lib
src\main.o: In function `main':
C:\Users\user\ndk-10.0.9-workspace\btoo\Simulator-Debug/..\src/main.c:31: undefined reference to `bt_device_init'
C:\Users\jbrooks\ndk-10.0.9-workspace\btoo\Simulator-Debug/..\src/main.c:40: undefined reference to `bt_device_deinit'
cc: C:/Users/jbrooks/Downloads/bbndk/host_10_0_9_52/win32/x86/usr/bin/ntox86-ld caught signal 1
Build error occurred, build is stopped
Time consumed: 571 ms.

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: newb problem

Probably you are missing library libbtapi. Should be added to your linker's options as  -l btapi

Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: newb problem

fixed.  thank you!

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.