blob: 0ff1ae8d51198668457d8c6f9777c7a7dbbdb6c1 [file] [log] [blame]
Linus Walleij6c04caa2006-03-29 17:33:51 +00001INSTALLATION OVERVIEW
2=====================
3
Linus Walleij0dd71e92006-05-04 18:47:07 +00004Once libmtp is built and installed, you will have the following files
5($PREFIX is the --prefix option given to the "configure" script and
6defaults to /usr/local/):
Linus Walleij6c04caa2006-03-29 17:33:51 +00007
Linus Walleij0dd71e92006-05-04 18:47:07 +00008 $PREFIX/lib/libmtp.a Static C library
9 $PREFIX/lib/libmtp.so.x.y.z Dynamic C library
10 $PREFIX/lib/libmtp.so.x A link to the library
11 $PREFIX/lib/libmtp.so A link to the library
12 $PREFIX/include/libmtp.h C header file for libmtp API
13 $PREFIX/lib/pkgconfig/libmtp.pc pkg-config configuration file
Linus Walleij6c04caa2006-03-29 17:33:51 +000014
Linus Walleij0dd71e92006-05-04 18:47:07 +000015Sample programs will be built in the "example" directory, and should
16help you get used to using the libmtp API, as well as provide some
17immediate gratification. Links to other programs using the libmtp
18API may be found at the homepage: http://libmtp.sourceforge.net/
Linus Walleij6c04caa2006-03-29 17:33:51 +000019
Linus Walleijd4637502009-06-14 23:03:33 +000020
Linus Walleijb8ee9252009-01-03 00:02:58 +000021Install From Distribution
22-------------------------
23
24You should probably prefer to install libmtp from the distribution
25source you're using. Last time we checked, libmtp was part of Ubuntu,
Linus Walleijd4637502009-06-14 23:03:33 +000026Fedora, OpenSUSE, Debian testing, Gentoo, FreeBSD ports and OpenBSD
Linus Walleijb8ee9252009-01-03 00:02:58 +000027packages/ports.
28
29
Linus Walleijd4637502009-06-14 23:03:33 +000030Dependencies
31------------
32
33To build libmtp you should only need development files for libusb.
34(Often named libusb-devel or similar.) For working with CVS versions
35you may need autoconf, automake, libtool, gettext(-devel).
36
Linus Walleijff3d2792012-02-18 21:45:15 +010037To enable the optional MTPZ support using libgcrypt you need the
38libgcrypt library installed as well.
39
Linus Walleijd4637502009-06-14 23:03:33 +000040
Linus Walleij0dd71e92006-05-04 18:47:07 +000041Shared Library Support
42----------------------
43
44Shared library linking is supported. You will need to 'make install'
45the library before you can execute the sample binaries, and add the
46libmtp install directory to your shared library search path.
47
48On Linux, you would add the line "/usr/local/lib" to your
49"/etc/ld.so.conf" or as a oneliner in for example a
50"/etc/ld.so.conf.d/local.conf" file and run the
Linus Walleijd4637502009-06-14 23:03:33 +000051program "ldconfig" to scan in the shared libraries at
52the new path. This is a part of the Linux shared library
Linus Walleij0dd71e92006-05-04 18:47:07 +000053loader actually.
54
55To access the library from real odd locations you can use
56the LD_LIBRARY_PATH environment variable by setting it before
57you run your program, for example:
58
59 % export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
60 % my_program
61
Linus Walleijb2d4ff42012-07-17 14:43:31 +020062To check whether you need to do something this:
63
64 % ldd /usr/lib/rhytmbox/plugins/mtpdevice/libmtpdevice.so | grep mtp
65 % ldd /usr/bin/gnomad2 | grep mtp
66
67If the program is linking to a packaged version of libmtp
68it will likely say something like this:
69
70 libmtp.so.N => /usr/lib/libmtp.so.N (0xb4e4b000)
71
72In this case you may have your freshly compiled library in
73/usr/local/lib or something like that, and you need to do the
74LD_LIBRARY_PATH trick. Verify by using "ldd" again.
75
Linus Walleij0dd71e92006-05-04 18:47:07 +000076This way of enabling the library to link is a workaround hack.
77Note that the LD_LIBRARY_PATH is actually supposed to be used for
78testing, not production systems or distributions. It is commonly
79used as a workaround when a user is installing libraries in her/his
80home directory however. Read more about this environment variable
81here: http://www.visi.com/~barr/ldpath.html
82
83The shared library comes with different interface version numbers,
84for example libmtp.so.4, libmtp.so.5 and so forth. This is used so
85that both old and new libmtp libraries shall be able to coexist on
Linus Walleijd4637502009-06-14 23:03:33 +000086the same system. When you compile your programs they will typically
87bind to the latest version of the shared library. A link to the
Linus Walleij0dd71e92006-05-04 18:47:07 +000088latest version is always provided as $PREFIX/lib/libmtp.so.
89
90libusb Support
91--------------
92
93This package depends on libusb. Get libusb from sourceforge at:
94
95 http://www.sourceforge.net/projects/libusb/
96
Linus Walleij63a92582006-06-03 20:36:35 +000097On Linux, please use the very latest version you can get, between
980.1.8 and 0.1.12 a lot of things happened which pertains to
99the udev hotplugging support, see below.
100
Linus Walleij0dd71e92006-05-04 18:47:07 +0000101
102BASIC BUILD PROCEDURE
103=====================
104
105To build the package:
106
Linus Walleij925cd452010-12-05 21:26:48 +0000107 % ./configure
Linus Walleij0dd71e92006-05-04 18:47:07 +0000108 % make
109 % make install
110
111By default, libmtp will add the program-prefix "mtp-" to all the
112example programs prior to installation. The program-prefix option
113makes libmtp sample programs avoid collision with other programs like
Linus Walleij284aacb2007-08-11 21:17:36 +0000114sox' "play" program. If the default prefix for some reason fail,
115try to tag on "--program-prefix=mtp-" to the "configure" command.
116
Linus Walleij925cd452010-12-05 21:26:48 +0000117The "libexedir" in the configure file is hardcoded to /lib/udev to
Linus Walleij1774a8e2010-12-05 20:01:53 +0000118make the mtp-probe (which is built for Linux only) install into
Linus Walleij925cd452010-12-05 21:26:48 +0000119that directory. This is the only location that makes sens for this
120executable.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000121
122if you want to install the documentation type:
123
124 % make install-docs
125
126if you checked out the sources from CVS, you must first run the
127autogen.sh script that generates all the GNU autotools files.
Linus Walleij362d13e2009-08-02 19:59:21 +0000128Notice that this requires GNU autoconf, automake and libtool and
129possibly some other packages like gettext, readline, intltool and
130other M4 macro sources. This is done with:
Linus Walleij0dd71e92006-05-04 18:47:07 +0000131
132 % ./autogen.sh
133
134
135Linux hotplugging
136-----------------
137
138After compilation and installation you may (and should) add hotplugging
139support by running the hotplug script, if your distribution supports
140hotplugging (all do). This typically means you have something
141in /etc/hotplug and that hotplugging is started when you boot your
142machine in a script named /etc/init.d/hotplug or similar.
143
144Activate hotplugging by running:
145
146 %./hotplug.sh
147
148Hotplug will (typically) use the device map file installed by hotplug.sh
149at /etc/hotplug/usb/libmtp.usermap to lift the device to userspace for the
150current user by running the script /etc/hotplug/usb/libmtp.sh. If
151you have the program "resmgr" installed (currently used only by SuSE to
152our knowledge) that program will be used for enabling desktop user
153access, otherwise the current user of the desktop will be determined
154from files in /var/run. (See the script "libmtp.sh" for details.)
155
156
157Linux udev hotplugging
158----------------------
159
160Newer Linux distributions have dropped support for the old hotplug system
161and rely solely on udev, and rules stored below /etc/udev/rules.d to
162handle permissions and actions on device connections. It's quite solid
163but the whole thing is rather shaky when it comes to such things as
164custom devices handled solely by libusb, which is what libmtp and for
165example SANE backends use.
166
167The libmtp.rules file that comes with libmtp can be used as a starter.
168
Linus Walleijc4cd50b2011-01-08 22:50:07 +0000169This will set the environment variables ID_MEDIA_PLAYER and
170ID_MTP_DEVICE to "1" and the former one will be recognized by the
171scripts distributed by recent versions of udev to be a
172console-writable device that should be accessible for all
173users.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000174
Linus Walleijc4cd50b2011-01-08 22:50:07 +0000175Ancient udev, HAL, libusb
176-------------------------
177
178The old script for udev used to set the device access to "666"
179which is rather nasty (not that big security issue, unless you
180think someone will break into your jukebox) some systems used
181to let PAM do this by placing a configuration file in
182/etc/security/ somewhere. Then it was replaced with simple
183udev rules.
184
185At one point HAL was used to take devices detected by udev and
186signal to userspace that they were available and provide some
187information about them. This was unnecessary middleware, it has
188been killed and most userspace applications now get their
189information directly from udev instead.
190
191In old libusb first you need a crazy rule that creates a device
192node in the /dev/bus/usb hierarchy whenever any USB device is
193connected. The script has this at the top, you can comment it
194in if your distribution does not already create these device
195nodes.
196
197Then libusb may need to be patched to recognize this hierarchy.
Linus Walleij0dd71e92006-05-04 18:47:07 +0000198The 0.1.12 version is the first which is properly fixed.
199
Linus Walleij0dd71e92006-05-04 18:47:07 +0000200
201
202If you cannot run hotplugging
203-----------------------------
204
205If you have a distro without hotplugging enabled try this as root:
206
207 % chmod -R a+w /proc/bus/usb
208
209You have to do this again every time you unplug/replug your USB cable
210or restart the jukebox, every time you quit libnjb and restart it,
211etc etc etc an alternative is to run libmtp as root which works just fine.
212The problem is to somehow assure that you (ie the current user) always
213has write access on /proc/bus/usb/*
214
215You can find the Linux hotplug project at:
216http://linux-hotplug.sourceforge.net/
Linus Walleijd3b78572007-08-24 21:28:24 +0000217
218
219Compilation for embedded devices
220--------------------------------
221
222Problems with Autoconf complaining about a missing malloc() function
223during cross-compilation can be solved with this hack if you're using
224glibc:
225
226 % export ac_cv_func_malloc_0_nonnull=yes
227 % ./configure
228
229If you're using uclibc you may have to smack in a custom rpl_malloc()
230function in your program, see the Autoconf texinfo documentation.
231
232See further:
Linus Walleijc868cbc2011-02-09 20:19:25 +0100233http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC
234
235Compilation for Solaris/SunOS
236-----------------------------
237
Darran Kartaschew11082d32011-12-13 00:42:01 +0100238libmtp builds on Solaris/SunOS with either gcc or SunStudio 12. It does
239require GNU Make (aka gmake) to be installed. Building libmtp on Solaris
24010 and Solaris 11 differ slightly, so alternate instructions are provided
241for each Solaris version.
242
243For Solaris 10
244--------------
Linus Walleijc868cbc2011-02-09 20:19:25 +0100245
Darran90ec6e52011-02-13 17:53:20 +0100246To build using GCC:
Darran Kartaschew11082d32011-12-13 00:42:01 +0100247
Darran90ec6e52011-02-13 17:53:20 +0100248 % CFLAGS="I/usr/sfw/lib -L/usr/sfw/lib -R/usr/sfw/lib" MAKE=gmake \
249 INSTALL=/usr/ucb/install ./configure
250 % gmake
251 % gmake install
Linus Walleijc868cbc2011-02-09 20:19:25 +0100252
Darran Kartaschew11082d32011-12-13 00:42:01 +0100253Custom CLFAGS are required for libusb.so as it lives in /usr/sfw/lib,
254and this path is not in the default search path for ld. If these
255CFLAGS are not set, several components of ./configure will fail leading
Darran90ec6e52011-02-13 17:53:20 +0100256to a failed build.
Linus Walleijc868cbc2011-02-09 20:19:25 +0100257
Darran90ec6e52011-02-13 17:53:20 +0100258To build using SunStudio 12:
Linus Walleijc868cbc2011-02-09 20:19:25 +0100259
Darran90ec6e52011-02-13 17:53:20 +0100260 % CFLAGS="I/usr/sfw/lib -L/usr/sfw/lib -R/usr/sfw/lib" MAKE=gmake \
261 INSTALL=/usr/ucb/install CC=cc ./configure
262 % gmake
263 % gmake install
Linus Walleijc868cbc2011-02-09 20:19:25 +0100264
Linus Walleijc868cbc2011-02-09 20:19:25 +0100265
Darran90ec6e52011-02-13 17:53:20 +0100266General Notes:
Darran Kartaschew11082d32011-12-13 00:42:01 +0100267All MTP devices on Solaris 10u2+ are driven by the usb_mid driver, which
268will automatically export ugen device interfaces with the correct device
269permissions. No special configuration is required. See the usb_mid(7D)
270and ugen(7D) manpages and /usr/sfw/share/doc/libusb/libusb.txt for
Darran90ec6e52011-02-13 17:53:20 +0100271more information.
Darran Kartaschew11082d32011-12-13 00:42:01 +0100272
273For Solaris 11
274--------------
275
276Building libmtp on Solaris 11 is very similar to those instructions for
277Solaris 10, however libusb now lives in /usr/lib, and openusb is also
278available as an alternative USB library. Oracle does not provide a
279libusb v1.0 API compatible version of libusb, instead providing the older
280v0.1 API interface version of libusb. As mentioned, Oracle also provides
281the OpenUSB USB library as an alternate to libusb v1.0, however OpenUSB is
282not source or binary compatible with libusb.
283
284Before building/installing libmtp there are some components missing from
285the base Solaris 11 installation, and are required to be installed prior
286to building/installing libmtp. The 'libusbugen' package must be installed
287before libusb itself is usable on Solaris 11, alternatively the 'openusb'
288package may be used.
289
290To build using GCC:
291 % ./configure
292 % gmake
293 % sudo gmake install
294
295To build using SunStudio 12:
296 % CC=cc ./configure
297 % gmake
298 % sudo gmake install
299
300
301General Notes:
302All MTP devices on Solaris 11+ are driven by the usb_mid driver, which
303will automatically export ugen device interfaces with the correct device
304permissions. No special configuration is required. See the usb_mid(7D)
305and ugen(7D) manpages and /usr/share/doc/libusb/libusb.txt for more
306information.