Page 1 of 1

C++ NXT Bluetooth Library

Posted: 08 Jan 2012, 14:22
by salgfrancisco
I was wondering if anyone had successfully set up this library http://www.norgesgade14.dk/bluetoothlibrary.php in Visual Studio or Visual c++ Express. I have already used NXT++ with no problems however it lacks a lot of features.
It only mentions we need to add the files to our project, however it keeps returning different errors.
Could anyone provide a step-by-step guide on how to use it?

Re: C++ NXT Bluetooth Library

Posted: 11 Jan 2012, 03:08
by timpattinson
1. Download and extract
2. make a VC++ project
3. See my post here: https://sourceforge.net/apps/phpbb/mind ... ffel#p7160
4. Build

Re: C++ NXT Bluetooth Library

Posted: 11 Jan 2012, 20:10
by salgfrancisco
Ok, so i added the files to the project I created, but when compiling I get these errors:

]1>------ Build started: Project: NXT library, Configuration: Debug Win32 ------
1>Compiling...
1>bluetooth.cpp
1>c:\nxt c++ bluetooth library\bluetooth.cpp(42) : error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>main.cpp
1>c:\users\francis\documents\visual studio 2008\projects\nxt library\nxt library\main.cpp(5) : fatal error C1083: Cannot open include file: 'nxt.h': No such file or directory
1>Generating Code...
1>Build log was saved at "file://c:\Users\Francis\Documents\Visual Studio 2008\Projects\NXT library\NXT library\Debug\BuildLog.htm"
1>NXT library - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any ideas how to solve them?

Re: C++ NXT Bluetooth Library

Posted: 11 Jan 2012, 22:10
by timpattinson
Use a cast to convert the char* to LPCWSTR
For the other error, is nxt.h in the same directory as main.cpp?
If not, add the folder to the VC++ include path.

Re: C++ NXT Bluetooth Library

Posted: 12 Jan 2012, 19:44
by bullestock
timpattinson wrote:Use a cast to convert the char* to LPCWSTR
That's not a good idea if it really is a char pointer. Either change the project to compile as ANSI instead of Unicode, or change the call to CreateFile() to use CreateFileA().