Update the version of libimobiledevice bundled with the windows calibre build to support iOS 8

This commit is contained in:
Kovid Goyal 2014-11-15 16:52:18 +05:30
parent 870ad92a0d
commit c471e0d1e0

View File

@ -1,40 +1,35 @@
Notes on building libiMobileDevice for Windows Notes on building libiMobileDevice for Windows
========================================================= =========================================================
The following notes are intended to work in the calibre build environment described in
windows/notes.rst. In particular, third party dependencies like libxml2 and
openssl are assumed to have been built as described there.
1. Get source files, set up VS project 1. Get source files, set up VS project
2. Build libcnary 2. Build libcnary
3. Build libgen 3. Build libplist
4. Build libplist 4. Build libusbmuxd
5. Build libusbmuxd 5. Build libgen
6. Build libimobiledevice 6. Build libimobiledevice
7. Exporting libimobiledevice entry points 7. Finished
8. Finished
Get source files, set up VS project Get source files, set up VS project
------------------------------------- -------------------------------------
Starting with source downloaded from https://github.com/storoj/libimobiledevice-win32 Follow these steps::
mkdir $SW/private/imobiledevice && cd $SW/private/imobiledevice
Now create a new directory in which we will work:: git clone https://github.com/Polyfun/libimobiledevice-windows.git
mkdir imobiledevice cd libimobiledevice-windows && cp -r libcnary libgen vendors/include .. && cd ..
cp -r libcnary libgen vendors/include libimobiledevice libplist libusbmuxd imobiledevice git clone https://github.com/Polyfun/libplist.git
cd imobiledevice git clone https://github.com/Polyfun/libusbmuxd.git
rm `find . -name '*.props'` git clone https://github.com/Polyfun/libimobiledevice.git
rm `find . -name *.vcxproj*`
rm `find . -name *.txt`
cd ..
mv imobiledevice ~/sw/private/
In include/unistd.h, comment out line 11::
// #include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html.
Create a new VS 2008 Project Create a new VS 2008 Project
- File|New|Project… - File|New|Project…
- Visual C++: Win32 - Visual C++: Win32
- Template: Win32Project - Template: Win32Project
- Name: imobiledevice - Name: imobiledevice
- Location: Choose ~/sw/private - Location: Choose $SW/private
- Solution: (Uncheck the create directory for solution checkbox) - Solution: (Uncheck the create directory for solution checkbox)
- Click OK - Click OK
- Next screen, select Application Settings tab - Next screen, select Application Settings tab
@ -51,159 +46,64 @@ win32).
Build libcnary Build libcnary
------------------------- -------------------------
In VS Solution Explorer, right-click Solution 'imobiledevice', then click In VS Solution Explorer, right-click "Solution 'imobiledevice'", then click
Add|New Project. Add|Existing Project and choose libcnary.vcproj
- Name: libcnary
- Location: Add \imobiledevice to the end of the default location
- Visual C++: Win32, Template: Win32 Project
- Click OK
- Application Settings: Static library (not using precompiled headers)
- Click Finish
In VS Solution Explorer, select the libcnary project, Project->Show All files. In VS Solution Explorer, select the libcnary project, Right click->Build
- Right-click the include folder, select 'Include In Project'.
- Select all the .c files, right click, select 'Include In Project'
- Select all the .c files, right click -> Properties -> C/C++ -> Advanced -> Compile as C++ code
- Properties|Configuration Properties|C/C++:
General|Additional Include Directories:
"$(ProjectDir)\include"
- If 64bits, then Right click->Properties->Configuration Manager change
Win32 to x64 for the libcnary project and check the Build checkbox
- Right-click libcnary, Build. Should build with 0 errors, 0 warnings.
Build libplist Build libplist
--------------------- ---------------------
In VS Solution Explorer, right-click Solution 'imobiledevice', then click In VS Solution Explorer, right-click Solution 'imobiledevice', then click
Add|New Project. Add|Existing Project and select libplist.vcproj
- Name: libplist
- Visual C++: Win32, Template: Win32 Project
- Location: Add \imobiledevice to the end of the default location
- Click OK
- Application Settings: DLL (Empty project)
- Click Finish
In VS Solution Explorer, select the libplist project, then click the 'Show all files' In VS Solution Explorer, select the libplist project, right
button. click->Properties-Configuration
- Right-click the include folder, select Include In Project
- Right-click the src folder, select Include In Project
- Set 7 C files to compile as C++
Advanced|Compile As: Compile as C++ Code (/TP)
base64.c, bplist.c, bytearray.c, hashtable.c, plist.c, ptarray.c, xplist.c
- Properties|Configuration Properties|C/C++: - Properties|Configuration Properties|C/C++:
General|Additional Include Directories: General|Additional Include Directories:
$(ProjectDir)\include
$(SolutionDir)\include $(SolutionDir)\include
$(SolutionDir)\libcnary\include
$SW\include\libxml2 (if it exists) $SW\include\libxml2 (if it exists)
$SW\include (make sure this is last in the list) $SW\include (make sure this is last in the list)
- Properties|C/C++|Preprocessor - Properties -> Linker -> General -> Additional Library directories: $SW/lib (for libxml2.lib)
Preprocessor Definitions: Add the following items
__STDC_FORMAT_MACROS Project Dependencies:
plist_EXPORTS
- Properties -> Linker -> General -> Additional Library directories: ~/sw/lib (for libxml2.lib)
- Properties -> Linker -> Input -> Additional Dependencies: libxml2.lib
- Project Dependencies:
Depends on: libcnary Depends on: libcnary
- If 64bits, then Right click->Properties->Configuration Manager change
Win32 to x64 for the libcnary project and check the Build checkbox Right-click libplist, Build. Should build with 0 errors (there will be warnings
- Right-click libplist, Build. Should build with 0 errors (there will be about datatype conversion for the 64 bit build)
warnings about datatype conversion for the 64 bit build)
Build libusbmuxd Build libusbmuxd
---------------------- ----------------------
In VS Solution Explorer, right-click Solution 'imobiledevice', then click In VS Solution Explorer, right-click Solution 'imobiledevice', then click
Add|New Project. Add|Existing Project -> libusbmuxd.vcproj
- Name: libusbmuxd
- Visual C++: Win32, Template: Win32 Project
- Location: Add \imobiledevice to the end of the default location
- Click OK
- Application Settings: DLL (Empty project)
- Click Finish
In VS Solution Explorer, select the libusbmuxd project, then click the 'Show all files' In VS Solution Explorer, select the libusbmuxd project, then right
button. click->Properties->Configuration.
- Select all 7 files, right-click, Include In Project.
- Set 3 C files to compile as C++
Advanced|Compile As: Compile as C++ Code (/TP)
libusbmuxd.c, sock_stuff.c, utils.c
- Properties|Configuration Properties|C/C++: - Properties|Configuration Properties|C/C++:
General|Additional Include Directories: General|Additional Include Directories:
$(SolutionDir)\include $(SolutionDir)\include
$(SolutionDir)\libplist\include $(SolutionDir)\libplist\include
- Properties|Linker|Input|Additional Dependencies:
ws2_32.lib
- Properties|C/C++|Preprocessor
Preprocessor Definitions: add 'HAVE_PLIST'
- Project Dependencies:
Depends on: libplist
- Edit sock_stuff.c #227:
fprintf(stderr, "%s: gethostbyname returned NULL address!\n",
__FUNCTION__);
- Edit libusbmuxd\usbmuxd.h, insert at #26:
#ifdef LIBUSBMUXD_EXPORTS
# define LIBUSBMUXD_API __declspec( dllexport )
#else
# define LIBUSBMUXD_API __declspec( dllimport )
#endif
Then, at each function, insert LIBUSBMUXD_API ahead of declaration:
usbmuxd_subscribe
usbmuxd_unsubscribe
usbmuxd_get_device_list
usbmuxd_device_list_free
usbmuxd_get_device_by_udid
usbmuxd_connect
usbmuxd_disconnect
usbmuxd_send
usbmuxd_recv_timeout
usbmuxd_recv
usbmuxd_set_use_inotify
usbmuxd_set_debug_level
- If 64bits, then Right click->Properties->Configuration Manager change Project Dependencies:
Win32 to x64 for the libcnary project and check the Build checkbox Depends on: libplist
- Right-click libusbmuxd, Build. Should build with 0 errors, 10 or 14 warnings
Right-click libusbmuxd, Build. Should build with 0 errors, many warnings
Build libgen Build libgen
----------------------- -----------------------
In VS Solution Explorer, right-click Solution 'imobiledevice', then click In VS Solution Explorer, right-click Solution 'imobiledevice', then click
Add|New Project. Add|Existing Project -> libgen.vcpro
- Name: libgen
- Visual C++: Win32, Template: Win32 Project
- Location: Add \imobiledevice to the end of the default location
- Click OK
- Application Settings: Static library (not using precompiled headers)
- Click Finish
In VS Solution Explorer, select the libgen project, then click the 'Show all files' Right-click libgen, Build. Should build with 0 errors, 0 warnings.
button.
- Select libgen.cpp and libgen.h, right click, select 'Include In Project'
- Open libgen.cpp, comment out line 5::
// #include <fileapi.h>
(This is a Windows 8 include file, not needed to build in Win 7)
- If 64bits, then Right click->Properties->Configuration Manager change
Win32 to x64 for the libcnary project and check the Build checkbox
- Right-click libgen, Build. Should build with 0 errors, 0 warnings.
Build libimobiledevice Build libimobiledevice
---------------------------- ----------------------------
In VS Solution Explorer, right-click Solution 'imobiledevice', then click In VS Solution Explorer, right-click Solution 'imobiledevice', then click
Add|New Project. Add|Existing Project -> libimobiledevice.vcproj
- Name: libimobiledevice
- Visual C++: Win32, Template: Win32 Project
- Location: Add \imobiledevice to the end of the default location
- Click OK
- Application Settings: DLL (Empty project)
- Click Finish
- Right-click the include folder, select Include In Project
- Right-click the src folder, select Include In Project
- Set .c files to compile as C++
Advanced|Compile As: Compile as C++ Code (/TP)
- Properties|Configuration Properties|C/C++: - Properties|Configuration Properties|C/C++:
General|Additional Include Directories: General|Additional Include Directories:
$(ProjectDir)\include $(ProjectDir)\include
@ -215,138 +115,20 @@ Add|New Project.
- Properties -> Linker -> General -> Additional library directories: - Properties -> Linker -> General -> Additional library directories:
$SW\private\openssl\lib $SW\private\openssl\lib
$(OutDir) $(OutDir)
- Properties|Linker|Input|Additional Dependencies: - Properties -> Build Events ->Post Build Event -> Remove the post build event (we will copy the dlls manually)
libeay32.lib
ssleay32.lib Right click-> Project Dependencies:
libplist.lib
libgen.lib
libusbmuxd.lib
ws2_32.lib
- Properties|C/C++|Preprocessor
Preprocessor Definitions:
ASN1_STATIC
HAVE_OPENSSL
__LITTLE_ENDIAN__
_LIB
- Project Dependencies:
libcnary libcnary
libgen libgen
libplist libplist
libusbmuxd libusbmuxd
- Edit afc.c #35:
Comment out lines 35-37 (Synchapi.h is a Windows 8 include file)
- Edit userprofile.c and add at line 25:
#include <Windows.h>
- Edit libimobiledevice\include\libimobiledevice\afc.h
At #26, insert
#define AFC_API __declspec( dllexport )
Then, at each function, insert AFC_API ahead of declaration
afc_client_new
afc_client_free
afc_get_device_info
afc_read_directory
afc_get_file_info
afc_file_open
afc_file_close
afc_file_lock
afc_file_read
afc_file_write
afc_file_seek
afc_file_tell
afc_file_truncate
afc_remove_path
afc_rename_path
afc_make_directory
afc_truncate
afc_make_link
afc_set_file_time
afc_get_device_info_key
- Edit libimobiledevice\include\libimobiledevice\housearrest.h Right-click libimobiledevice, Build.
At #26, insert 0 errors, many warnings.
#define HOUSE_ARREST_API __declspec( dllexport )
Then, at each function, insert HOUSE_ARREST_API ahead of declaration
house_arrest_client_new
house_arrest_client_free
house_arrest_send_request
house_arrest_send_command
house_arrest_get_result
afc_client_new_from_house_arrest_client
- Edit libimobiledevice\include\libimobiledevice\installation_proxy.h
At #26, insert
#define INSTALLATION_PROXY_API __declspec( dllexport )
Then, at each function, insert INSTALLATION_PROXY_API ahead of declaration
instproxy_client_new
instproxy_client_free
instproxy_browse
instproxy_install
instproxy_upgrade
instproxy_uninstall
instproxy_lookup_archives
instproxy_archive
instproxy_restore
instproxy_remove_archive
instproxy_client_options_new
instproxy_client_options_add
instproxy_client_options_free
- Edit libimobiledevice\include\libimobiledevice\libimobiledevice.h
At #26, insert
#define LIBIMOBILEDEVICE_API __declspec( dllexport )
Then, at each function, insert LIBIMOBILEDEVICE_API ahead of declaration
idevice_set_debug_level
idevice_event_subscribe
idevice_event_unsubscribe
idevice_get_device_list
idevice_device_list_free
idevice_new
idevice_free
idevice_connect
idevice_disconnect
idevice_connection_send
idevice_connection_receive_timeout
idevice_connection_receive
idevice_get_handle
idevice_get_udid
- Edit libimobiledevice\include\libimobiledevice\lockdown.h
At #27, insert
#define LOCKDOWN_API __declspec( dllexport )
Then, at each function, insert LOCKDOWN_API ahead of declaration
lockdownd_client_new
lockdownd_client_new_with_handshake
lockdownd_client_free
lockdownd_query_type
lockdownd_get_value
lockdownd_set_value
lockdownd_remove_value
lockdownd_start_service
lockdownd_start_session
lockdownd_stop_session
lockdownd_send
lockdownd_receive
lockdownd_pair
lockdownd_validate_pair
lockdownd_unpair
lockdownd_activate
lockdownd_deactivate
lockdownd_enter_recovery
lockdownd_goodbye
lockdownd_getdevice_udid
lockdownd_get_device_name
lockdownd_get_sync_data
lockdownd_data_classes_free
lockdownd_service_descriptor_free
- If 64bits, then Right click->Properties->Configuration Manager change
Win32 to x64 for the libcnary project and check the Build checkbox
- Right-click libimobiledevice, Build.
0 errors, 60 warnings.
Copy the DLLs Copy the DLLs
----------------- -----------------
Run:: Run::
cp `find . -name '*.dll'` ~/sw/bin/ cp `find Release -name '*.dll'` ~/sw/bin/