Search code examples
windows-8linkervisual-studio-2012bluetoothlnk2019

Visual Studio 2012: Unresolved external symbol _BluetoothFindFirstRadio


I'm trying to use some Bluetooth functions (http://msdn.microsoft.com/en-us/library/windows/desktop/aa362927(v=vs.85).aspx) in a Win32 Console Application project. After including the relevant headers, I get linker errors like the following during compilation:

Error   1   error LNK2019: unresolved external symbol _BluetoothFindFirstRadio@8 referenced in function _wmain

I've been assuming that I have failed to link to the Windows 8 SDK. Opening the project properties, my targeted framework is .NET 4.0 which I cannot change and there are no references I can add either.

I may be entirely off-base. How do I resolve this compilation error?

enter image description here


Solution

  • Since you're compiling native code (Win32), adding references won't work as they do in C#/.NET. What you need to do is;

    • Select "Properties" on your project.
    • Expand "Configuration Properties".
    • Expand "Linker".
    • Select "Input".
    • Add "Bthprops.lib" to "Additional Dependencies".

    Bthprops.lib is mentioned as needed in the BluetoothFindFirstRadio documentation.

    Compile, and all should be well.