I use gcc to complile the code
#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);
}
got
Undefined symbols for architecture x86_64: "_idevice_free", referenced from: _main in 1-af7b2e.o "_idevice_get_udid", referenced from: _main in 1-af7b2e.o "_idevice_new_with_options", referenced from: _main in 1-af7b2e.o ld: symbol(s) not found for architecture x86_64
while I have tried gcc -lstdc++ hello.c -o hello
it's still cann't be compiled.
You need to include the libimobiledevice
library, try this:
gcc hello.c -o hello -limobiledevice-1.0