Linux无线工具和对“ iw_scan”的未定义引用

时间:2018-09-18 14:22:21

标签: c++ linux debian wireless

我正在尝试在C ++的debian系统上使用Wireless Tools for Linux

当我尝试编译我的代码时:

#include <iwlib.h>
#include <string>

void connect(const char* ssid, const char* pw, const char* interface) {
    wireless_scan_head head;
    wireless_scan* result;
    iwrange range;
    int sock;

    // Open kernel socket:
    sock = iw_sockets_open();

    // Get scan metadata:
    if (iw_get_range_info(sock, interface, &range)) {
        // log_error(LOGGER_PREFIX + "Failed to get range info!");
        exit(1);
    }

    // Scan:
    if (iw_scan(sock, const_cast<char*>(interface), range.we_version_compiled, &head) < 0) {
        // log_error(LOGGER_PREFIX + "Failed to perform iw_scan!");
        exit(2);
    }

    // Print results:
    result = head.result;
    printf("SSIDS:\n");
    while (NULL != result) {
        printf("%s\n", result->b.essid);
    result = result->next;
  }
}

使用g++会导致: undefined reference to 'iw_scan' collect2: error: ld returned 1 exit status

我无法用以下问题的答案解决问题:What is an undefined reference/unresolved external symbol error and how do I fix it?

0 个答案:

没有答案