Click to See Complete Forum and Search --> : error with Bluetooth and RFCOMM sockets


napsy
July 16th, 2009, 03:24 AM
Hello. I'm trying to construct a simple program that connects to a bluetooth device using RFCOMM sockets. I've stumbled on a page that has some sample code: http://www.lenholgate.com/archives/000102.html

I have installed Windows SDK and Visual Studio (express edition). The problem is that if I compile my program, the compiler dumps a bunch of errors. I've come to the conclusion that the header Ws2bth.h is giving those errors even if I write an "empty" C++ program and only include the header. Is there a reaon wy this is happening? Do I need to turn on a switch to the compiler. Please help.

Greets,
Luka

MikeAThon
July 20th, 2009, 03:53 PM
Your #include files are probably included in the wrong order. Try it in the following order:

#include <Winsock2.h>
#include <Bthsdpdef.h>
#include <Ws2bth.h>
#include <BluetoothAPIs.h>

See "Using Bluetooth" at http://msdn.microsoft.com/en-us/library/aa363058(VS.85).aspx which explains this ordering of includes.

Mike