tihmstar / usbmuxd2

A socket daemon written in C++ to multiplex connections from and to iOS devices over USB and WIFI
GNU Lesser General Public License v3.0
188 stars 40 forks source link

Failed to build usbmuxd2 on Ubuntu 18.04 #10

Closed lostwindsenril closed 3 years ago

lostwindsenril commented 3 years ago

Hi, I'm trying to build this repo on Ubuntu 18.04, but I got this error:

libtool: link: g++ -I../usbmuxd2 -I/usr/local/include -I/usr/include/libusb-1.0 -I/usr/local/include -g -O2 -DCUSTOM_LOGGING=\"log.h\" -std=c++17 -o usbmuxd usbmuxd-main.o usbmuxd-log.o usbmuxd-Client.o usbmuxd-Muxer.o usbmuxd-TCP.o usbmuxd-SockConn.o usbmuxd-Device.o usbmuxd-Event.o Devices/usbmuxd-USBDevice.o Devices/usbmuxd-WIFIDevice.o Manager/usbmuxd-Manager.o Manager/DeviceManager/usbmuxd-DeviceManager.o Manager/DeviceManager/usbmuxd-USBDeviceManager.o Manager/DeviceManager/usbmuxd-WIFIDeviceManager-avahi.o Manager/DeviceManager/usbmuxd-WIFIDeviceManager-mDNS.o Manager/usbmuxd-ClientManager.o sysconf/usbmuxd-sysconf.o sysconf/usbmuxd-preflight.o -L/usr/local/lib -lusb-1.0 /usr/local/lib/libimobiledevice-1.0.so /usr/local/lib/libplist-2.0.so -lavahi-common -lavahi-client /usr/local/lib/libgeneral.so -lstdc++fs -pthread usbmuxd-log.o: In function usbmuxd_log': /home/ubuntu/usbmuxd2/usbmuxd2/log.c:56: undefined reference toassure' /home/ubuntu/usbmuxd2/usbmuxd2/log.c:58: undefined reference to `assure' collect2: error: ld returned 1 exit status Makefile:514: recipe for target 'usbmuxd' failed make[2]: [usbmuxd] Error 1 make[2]: 离开目录“/home/ubuntu/usbmuxd2/usbmuxd2” Makefile:430: recipe for target 'all-recursive' failed make[1]: [all-recursive] Error 1 make[1]: 离开目录“/home/ubuntu/usbmuxd2” Makefile:362: recipe for target 'all' failed make: *** [all] Error 2

I think I've strictly observe the Readme guide, and what's more I have tried to do something for solving this problem:

  1. make and install libusbmuxd from tihmstar's fork, instead of the libimobiledevice official ones. But I got

    /usr/bin/ld: cannot find -lusbmuxd-2.0

when making libimobiledevice. so I reinstalled the official libusbmuxd. After that, I build tihmstar's libimobiledevice and usbmuxd2, but still got that error when compiling usbmuxd2.

  1. using clang to compile instead of gcc, but still failed:

    /usr/bin/ld: usbmuxd-log.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status Makefile:514: recipe for target 'usbmuxd' failed

I'm a Linux user with some experience,but unfamiliar with coding, especially in lower layer of system. I have strong interest in hosting a private iOS wireless backup node, but I stucked in this step. Appreciate someone's help in advance!

lostwindsenril commented 3 years ago

Full log here: https://shweng-my.sharepoint.cn/:t:/g/personal/admin_shweng_partner_onmschina_cn/EZaqRDCfeIBAm0KPwyxHxTwBImZGJy0-zna5Bh6iQDJrWw?e=ji2StQ

lostwindsenril commented 3 years ago

Finally I find out the solution: just replace "assure" with "cassure" in usbmuxd2/usbmuxd2/log.c. Now it works well.

matakko commented 3 years ago

Thanks it fix the make for me . Im still having issue to get the service running , im using "usbmuxd -v --user root start" : i can see My UDID , i can get the trust device but after preflight : failed to recv_data on client 5 with error=client 5 disconnected! code=6946826

matakko commented 3 years ago

Sorry to ask again lostwindsenril , did you get the service run after install ? Did you replace "assure" with "cassure" on other files than log.c.? here is my logs of starting the service.

root@raspberrypi:# usbmuxd -v --user root start [14:05:40.010][3] starting usbmuxd2 version: 0.42-d43ab73753a5b7b6d9c713b42b31d4d2c6230498-RELEASE [14:05:40.011][3] Loaded config [14:05:40.011][3] starting usbmuxd2 version: 0.42-d43ab73753a5b7b6d9c713b42b31d4d2c6230498-RELEASE [14:05:40.012][3] Inited ClientManager [14:05:40.014][3] Not dropping privileges to root [14:05:40.014][3] USBDeviceManager libusb 1.0 [14:05:40.039][3] Registering for libusb hotplug events [14:05:40.039][3] Found new device with v/p 05ac:12ab at 1-5 [14:05:40.039][4] Found interface 1 with endpoints 04/85 for device 1-5 [14:05:40.040][4] Using wMaxPacketSize=512 for device 1-5 [14:05:40.040][3] USB Speed is 480 MBit/s for device 1-5 [14:05:40.040][3] Inited USBDeviceManager [14:05:40.041][3] Got lang ID 1033 for device 1-5 [14:05:40.042][3] Got serial '[MYUDID]' for device 1-5 (0x99f408) [14:05:40.045][3] Connected to v2.0 device [MYUDID] on location 0x10005 [14:05:40.046][3] preflighting device [MYUDID] [14:05:40.049][1] failed to recv_data on client 6 with error=client 6 disconnected! code=6946826 [14:05:40.050][3] killing client 6 [14:05:40.051][3] Starting TCP connection [14:05:40.053][3] TCP Connected to device [14:05:40.054][1] failed to recv_data on client -1 with error=graceful kill code=25165834 [14:05:40.055][3] killing client -1 [14:05:40.056][3] Inited WIFIDeviceManager [14:05:40.056][4] Initialization complete [14:05:40.056][4] Enabled exit on SIGUSR1 if no devices are attached. Start a new instance with "--exit" to trigger. [14:05:40.062][1] failed to recv_data on client 19 with error=client 19 disconnected! code=6946826 [14:05:40.062][3] killing client 19 [14:05:40.071][1] failed to recv_data on client 20 with error=client 20 disconnected! code=6946826 [14:05:40.071][3] killing client 20 [14:05:40.227][1] failed to recv_data on client 19 with error=client 19 disconnected! code=6946826 [14:05:40.227][3] killing client 19 [14:05:40.260][1] failed to recv_data on client 20 with error=client 20 disconnected! code=6946826 [14:05:40.260][3] killing client 20 [14:05:40.261][1] failed to recv_data on client 21 with error=client 21 disconnected! code=6946826 [14:05:40.261][3] killing client 21 [14:05:40.283][1] failed to recv_data on client 20 with error=client 20 disconnected! code=6946826 [14:05:40.283][3] killing client 20 [14:05:40.319][3] preflight_device: Finished preflight on device [MYUDID] [14:05:40.323][3] killing TCP 18 [14:05:40.324][1] no connection found with snum=1 [14:05:40.682][1] failed to recv_data on client 21 with error=client 21 disconnected! code=6946826 [14:05:40.683][3] killing client 21 ^C[14:05:46.954][3] Caught signal 2, exiting [14:05:46.954][4] main reached cleanup [14:05:46.954][3] killing device [MYUDID] [14:05:46.954][3] [destroying] ClientManager [14:05:46.954][3] killing device [MYUDID] [14:05:46.955][1] failed to handle client 18 with error=8060937 [14:05:46.955][3] killing client 18 [14:05:46.956][1] failed to recv_data on client -1 with error=assure failed code=7077898 [14:05:46.960][4] done!

matakko commented 3 years ago

Got it fix, launching daemonize made the trick for me : usbmuxd -s -d --user root start

root@raspberrypi:/lib/systemd/system# service usbmuxd status
● usbmuxd.service - Socket daemon for the usbmux protocol used by Apple devices
   Loaded: loaded (/lib/systemd/system/usbmuxd.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2021-07-25 14:39:40 +07; 4min 5s ago
     Docs: man:usbmuxd(8)
 Main PID: 1262 (usbmuxd)
    Tasks: 6 (limit: 2062)
   CGroup: /system.slice/usbmuxd.service
           └─1262 /usr/sbin/usbmuxd -s -d --user root start

Thanks again for the log.c fix !

lostwindsenril commented 3 years ago

Got it fix, launching daemonize made the trick for me : usbmuxd -s -d --user root start

root@raspberrypi:/lib/systemd/system# service usbmuxd status
● usbmuxd.service - Socket daemon for the usbmux protocol used by Apple devices
   Loaded: loaded (/lib/systemd/system/usbmuxd.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2021-07-25 14:39:40 +07; 4min 5s ago
     Docs: man:usbmuxd(8)
 Main PID: 1262 (usbmuxd)
    Tasks: 6 (limit: 2062)
   CGroup: /system.slice/usbmuxd.service
           └─1262 /usr/sbin/usbmuxd -s -d --user root start

Thanks again for the log.c fix !

That's great.

sepsky commented 1 year ago

Hi @lostwindsenril I'm getting a similar error as you were getting: Aug 08 15:22:24 cet147 usbmuxd[1107]: [15:22:24.123][1] failed to recv_data on client 6 with error=client 6 disconnected! c>

I've run the above command @hjsm23 suggested, and my usbmuxd is running (I can confirm it with sudo service usbmuxd status)

Is there something I need to do with sockets / dns ? I'm sorry that even though I've been working with iOS / tvOS for a long time, I'm ashamedly not familiar with non-apple communication with apple devices.

If any help, my Avahi is finding my device fine:

   hostname = [atv-1.local]
   address = [xx.xx.xx.xx]
   port = [xxxx]
   txt = ["LocalAirPlayReceiverPairingIdentity=3FB99FE2-3320-40A1-D6B9-6A405211080D" "SystemBuildVersion=18L204" "UniqueIdentifier=3FB99FE2-3320-40A1-D6B9-6A405211080D" "Name=atv_1" "macAddress=xx:xx:xx:xx:xx:xx" "BluetoothAddress=??\027ê" "AllowPairing=YES" "ModelName=Apple TV"]
=   eth0 IPv6 dl_atv_1                                      _companion-link._tcp local

(my ate is connected to same lan as my raspberry pi)

Thanks again and if I left anything unclear, please let me know and I'll get the information.

matakko commented 1 year ago

Hello did you try : systemctl daemon-reload

Then it should be ok, usbmuxd -f -v idevicepair pair (if usb) idevicepair pair wifi (if wifi)

from my memory.

sepsky commented 1 year ago

Hi @hjsm23

Thanks a lot for messaging and the suggestions.

I followed your suggestion, and had the following:


- usbmuxd -f -v:
I ran it, but in usbmuxd2 there's no `-f` option. I did run `usbmuxd -v` and got this: 

[13:41:05.909][3] starting usbmuxd2 version: 0.46-753b79eaf317c56df6c8b1fb6da5847cc54a0bb0-DEBUG [13:41:05.909][5] mlck inited [13:41:05.910][3] Loaded config [13:41:05.910][3] starting usbmuxd2 version: 0.46-753b79eaf317c56df6c8b1fb6da5847cc54a0bb0-DEBUG [13:41:05.911][3] Inited ClientManager [13:41:05.911][5] [Client] initializing Client 5 [13:41:05.911][3] USBDeviceManager libusb 1.0 [13:41:05.911][5] add_client 5 [13:41:05.911][5] Client command in fd 5 len 435 ver 1 msg 8 tag 1 [13:41:05.911][5] send_pkt fd 5 tag 1 msg 8 payload_length 278 [13:41:05.911][5] Client 5 now LISTENING [13:41:05.911][5] notify_alldevices(5) [13:41:05.918][3] Registering for libusb hotplug events [13:41:05.918][3] Inited USBDeviceManager [13:41:05.918][5] WIFIDeviceManager avahi-client [13:41:05.921][5] WIFIDeviceManager created avahi service_browser [13:41:05.921][3] Inited WIFIDeviceManager [13:41:05.921][4] Initialization complete [13:41:05.931][5] (Browser) CACHE_EXHAUSTED

[13:41:06.145][5] (Browser) NEW: service 'xx:xx:xx:xx:xx:xx@xxxx::xxxx::xxxx::xxxx' of type '_apple-mobdev2._tcp' in domain 'local'

[13:41:06.145][5] Service 'xx:xx:xx:xx:xx:xx@xxxx::xxxx::xxxx::xxxx' of type '_apple-mobdev2._tcp' in domain 'local':

[13:41:06.146][5] failed to find uuid for mac=xx:xx:xx:xx:xx:xx with error=19267603 (macaddr=xx:xx:xx:xx:xx:xx is not paired) [13:41:06.933][5] (Browser) ALL_FOR_NOW

[13:41:09.245][5] (Browser) NEW: service 'xx:xx:xx:xx:xx:xx@xxxx::xxxx::xxxx::xxxx' of type '_apple-mobdev2._tcp' in domain 'local'

[13:41:09.248][5] Service 'xx:xx:xx:xx:xx:xx@xxxx::xxxx::xxxx::xxxx' of type '_apple-mobdev2._tcp' in domain 'local':

[13:41:09.249][5] failed to find uuid for mac=xx:xx:xx:xx:xx:xx with error=19267603 (macaddr=xx:xx:xx:xx:xx:xx is not paired)


- idevicepair pair wifi:
I ran this, but got this error:

No device found.

However, in my usbmuxd2 window (I didn't ^C it), I get this when I ran the command: 

[13:43:40.937][5] [Client] initializing Client 8 [13:43:40.938][5] add_client 8 [13:43:40.938][5] Client command in fd 8 len 428 ver 1 msg 8 tag 1 [13:43:40.938][5] send_pkt fd 8 tag 1 msg 8 payload_length 221 [13:43:40.939][1] failed to recv_data on client 8 with error=client 8 disconnected! code=7208970 [exception]: what=client 8 disconnected! code=7208970 line=110 file=Client.cpp commit count=46 commit sha =753b79eaf317c56df6c8b1fb6da5847cc54a0bb0


My ATV is in the pairing mode (the Settings -> Remotes and Devices -> Remote App and Devices).

Interestingly, if I run `idevicepair list`, I get nothing. Not even a log. 

I wonder...do we have to do anything with sockets / mDNS / dbus? Did you have to do anything with this when you created your setup? 

Thanks again, and if I should provide any other logs for any other tools, please let me know.