Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:37:18+00:00 2026-06-05T06:37:18+00:00

I’m a new stackoverflow user! I’m writing because I have some problems programming Bluetooth

  • 0

I’m a new stackoverflow user! I’m writing because I have some problems programming Bluetooth with C on my KUbuntu 12.04.

I’m trying to connect a device (LEGO Mindstorm Brick) to my notebook through a program that I’ve found in this pdf (Initiate connection):
NXT_Bluetooth_Handout

I installed the following packages:
– bluez-hcidump, communication debugging tool
– bluez, Linux Bluetooth stack and associated tools
– libBluetooth3, the BlueZ library
– libBluetooth-dev, the development files for linking to the BlueZ library

// Socket, used for Bluetooth socket
#include <sys/socket.h>
#include <sys/types.h>
// Bluetooth headers
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

Mainly I encountered two problems:
1) If I simply try to compile the program I get:

$ gcc -lm -lbluetooth nxt_bt_connect.c -o nxt_bt_connect
/tmp/ccSLdkpn.o: In function `init_bluetooth':
nxt_bt_connect.c:(.text+0x60): undefined reference to `str2ba'
collect2: ld returned 1 exit status

Where str2ba is a BlueZ function, which should work…ba2str is the other function which this library provides and it works without problem.

2) If I modify the code in order to use ba2str instead of str2ba function I get an error related to the socket:

$ gcc -lm -lbluetooth 1.c -o nxt_bt_connect2
1.c: In function ‘main’:
1.c:101:23: error: called object ‘socket’ is not a function

The problem is that I have no socket header is sys/, in fact if I run:

find /usr/include/ -name socket.h
 /usr/include/gtkmm-2.4/gtkmm/socket.h
 /usr/include/linux/socket.h
 /usr/include/asm-generic/socket.h
 /usr/include/giomm-2.4/giomm/socket.h
 /usr/include/x86_64-linux-gnu/sys/socket.h
 /usr/include/x86_64-linux-gnu/asm/socket.h
 /usr/include/x86_64-linux-gnu/bits/socket.h

Is there someone who knows how to solve those problems?
I hope to have described all situation in a sufficiently clear way…I apologize for my bad English!

Thank you very much!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:37:20+00:00Added an answer on June 5, 2026 at 6:37 am

    For the second question: you have to post the code you’ve written. Else we can’t figure out what’s bad.

    For the first question: you need to put the library linker flags as the last parameters when invoking GCC:

    gcc nxt_bt_connect.c -o nxt_bt_connect -lm -lbluetooth
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.