首页 > 解决方案 > 在 vs 2017 和 windows 10 中使用 BLuetoothAPIs.h 获取链接错误

问题描述

使用以下代码:

// Bluetooth_test.cpp : 定义控制台应用程序的入口点。//

#include "stdafx.h"
#include <windows.h>
#include "bthdef.h"
#include "BluetoothAPIs.h"

int main()
{
    BLUETOOTH_DEVICE_SEARCH_PARAMS bptsp;

    // set options for how we want to load our list of BT devices
    bptsp.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
    bptsp.fReturnAuthenticated = TRUE;
    bptsp.fReturnRemembered = TRUE;
    bptsp.fReturnUnknown = TRUE;
    bptsp.fReturnConnected = TRUE;
    bptsp.fIssueInquiry = TRUE;
    bptsp.cTimeoutMultiplier = 4;
    bptsp.hRadio = NULL;

    BLUETOOTH_DEVICE_INFO bptdi;
    bptdi.dwSize = sizeof(bptdi);

    HBLUETOOTH_DEVICE_FIND hFind = BluetoothFindFirstDevice(&bptsp, &bptdi);

    BluetoothFindDeviceClose(hFind);


    return 0;
}

我收到以下错误:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol _BluetoothFindFirstDevice@8 referenced in function _main Bluetooth_test  D:\VS 2017\repos\Bluetooth_test\Bluetooth_test\Bluetooth_test.obj   1   
Error   LNK1120 2 unresolved externals  Bluetooth_test  D:\VS 2017\repos\Bluetooth_test\Debug\Bluetooth_test.exe    1   
Error   LNK2019 unresolved external symbol _BluetoothFindDeviceClose@4 referenced in function _main Bluetooth_test  D:\VS 2017\repos\Bluetooth_test\Bluetooth_test\Bluetooth_test.obj   1   

我对 C++ 很陌生,我不知道为什么它不能编译请帮助我

Windows API:

https://docs.microsoft.com/en-us/windows/win32/api/bluetoothapis/nf-bluetoothapis-bluetoothfindfirstdevice https://docs.microsoft.com/en-us/windows/win32/api/bluetoothapis/nf -bluetoothapis-bluetoothfinddeviceclose

==== 编辑 ==== 就像 Mike Petrichenko 在评论中所说的那样,当我#pragma comment(lib, "Bthprops.lib");在包含下添加时,错误不会消失。

标签: c++bluetoothvisual-studio-2017windows-10lnk2019

解决方案


推荐阅读