首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我运行libimobiledevice入门代码,出错了吗?

我运行libimobiledevice入门代码,出错了吗?
EN

Stack Overflow用户
提问于 2020-10-23 15:04:22
回答 1查看 133关注 0票数 0

我用gcc编译代码

代码语言:javascript
复制
#include <stdio.h>
#include <stdlib.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/libimobiledevice.h>
#include <plist/plist.h>

int main()
{
    static char *udid = NULL;

    /* Device Handle */
    idevice_t device = NULL;

    /* Try to connect to first USB device */
    if (idevice_new_with_options(&device, NULL, IDEVICE_LOOKUP_USBMUX) != IDEVICE_E_SUCCESS) {
        printf("ERROR: No device found!\n");
        return -1;
    }

    /* Retrieve the udid of the connected device */
    if (idevice_get_udid(device, &udid) != IDEVICE_E_SUCCESS) {
    printf("ERROR: Unable to get the device UDID.\n");
    idevice_free(device);
    return -1;
    }

    /* Outputs device identifier */
    printf("Connected with UDID: %s\n", udid);

    /* Cleanup */
    idevice_free(device);
    free(udid);
}

得到

架构x86_64的未定义符号:"_idevice_free",引用自:_main in 1-af7b2e.o "_idevice_get_udid",引用自:_main in 1-af7b2e.o "_idevice_new_with_options",引用自:_main in 1-af7b2e.o ld:未找到架构x86_64的符号

虽然我已经尝试过gcc -lstdc++ hello.c -o hello,但它仍然不能被编译。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-06 06:32:07

您需要包含libimobiledevice库,请尝试执行以下操作:

gcc hello.c -o hello -limobiledevice-1.0

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64495409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档