blob: fc67dd80b2754880736ebf628d0451a731aa9bf9 [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 Walleijb8ee9252009-01-03 00:02:58 +000020Install From Distribution
21-------------------------
22
23You should probably prefer to install libmtp from the distribution
24source you're using. Last time we checked, libmtp was part of Ubuntu,
25Fedora, OpenSUSE, Debian testing, Gentoo, FreeBSD ports and OpenBSD
26packages/ports.
27
28
Linus Walleij0dd71e92006-05-04 18:47:07 +000029Shared Library Support
30----------------------
31
32Shared library linking is supported. You will need to 'make install'
33the library before you can execute the sample binaries, and add the
34libmtp install directory to your shared library search path.
35
36On Linux, you would add the line "/usr/local/lib" to your
37"/etc/ld.so.conf" or as a oneliner in for example a
38"/etc/ld.so.conf.d/local.conf" file and run the
39program "ldconfig" to scan in the shared libraries at
40the new path. This is a part of the Linux shared library
41loader actually.
42
43To access the library from real odd locations you can use
44the LD_LIBRARY_PATH environment variable by setting it before
45you run your program, for example:
46
47 % export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
48 % my_program
49
50This way of enabling the library to link is a workaround hack.
51Note that the LD_LIBRARY_PATH is actually supposed to be used for
52testing, not production systems or distributions. It is commonly
53used as a workaround when a user is installing libraries in her/his
54home directory however. Read more about this environment variable
55here: http://www.visi.com/~barr/ldpath.html
56
57The shared library comes with different interface version numbers,
58for example libmtp.so.4, libmtp.so.5 and so forth. This is used so
59that both old and new libmtp libraries shall be able to coexist on
60the same system. When you compile your programs they will typically
61bind to the latest version of the shared library. A link to the
62latest version is always provided as $PREFIX/lib/libmtp.so.
63
64libusb Support
65--------------
66
67This package depends on libusb. Get libusb from sourceforge at:
68
69 http://www.sourceforge.net/projects/libusb/
70
Linus Walleij63a92582006-06-03 20:36:35 +000071On Linux, please use the very latest version you can get, between
720.1.8 and 0.1.12 a lot of things happened which pertains to
73the udev hotplugging support, see below.
74
Linus Walleij0dd71e92006-05-04 18:47:07 +000075
76BASIC BUILD PROCEDURE
77=====================
78
79To build the package:
80
81 % ./configure
82 % make
83 % make install
84
85By default, libmtp will add the program-prefix "mtp-" to all the
86example programs prior to installation. The program-prefix option
87makes libmtp sample programs avoid collision with other programs like
Linus Walleij284aacb2007-08-11 21:17:36 +000088sox' "play" program. If the default prefix for some reason fail,
89try to tag on "--program-prefix=mtp-" to the "configure" command.
90
91On Linux you should then typically type (see below for details):
Linus Walleij0dd71e92006-05-04 18:47:07 +000092
93 % ./hotplug.sh
94
95you can achieve the same with
96
97 % ./configure --enable-hotplugging
98
99you can turn off some speed enhancements (for testing) with:
100
101 % ./configure --no-turbo
102
103if you want to install the documentation type:
104
105 % make install-docs
106
107if you checked out the sources from CVS, you must first run the
108autogen.sh script that generates all the GNU autotools files.
109Notice that this requires GNU autoconf, automake and libtool. This
110is done with:
111
112 % ./autogen.sh
113
114
115Linux hotplugging
116-----------------
117
118After compilation and installation you may (and should) add hotplugging
119support by running the hotplug script, if your distribution supports
120hotplugging (all do). This typically means you have something
121in /etc/hotplug and that hotplugging is started when you boot your
122machine in a script named /etc/init.d/hotplug or similar.
123
124Activate hotplugging by running:
125
126 %./hotplug.sh
127
128Hotplug will (typically) use the device map file installed by hotplug.sh
129at /etc/hotplug/usb/libmtp.usermap to lift the device to userspace for the
130current user by running the script /etc/hotplug/usb/libmtp.sh. If
131you have the program "resmgr" installed (currently used only by SuSE to
132our knowledge) that program will be used for enabling desktop user
133access, otherwise the current user of the desktop will be determined
134from files in /var/run. (See the script "libmtp.sh" for details.)
135
136
137Linux udev hotplugging
138----------------------
139
140Newer Linux distributions have dropped support for the old hotplug system
141and rely solely on udev, and rules stored below /etc/udev/rules.d to
142handle permissions and actions on device connections. It's quite solid
143but the whole thing is rather shaky when it comes to such things as
144custom devices handled solely by libusb, which is what libmtp and for
145example SANE backends use.
146
147The libmtp.rules file that comes with libmtp can be used as a starter.
148
149First you need a crazy rule that creates a device node in the
150/dev/bus/usb hierarchy whenever any USB device is connected. The
151script has this at the top, you can comment it in if your
152distribution does not already create these device nodes.
153
154Then libusb may need to be patched to recognize this hierarchy.
155The 0.1.12 version is the first which is properly fixed.
156
157The script sets the device access to "666" which is rather nasty
158(not that big security issue, unless you think someone will break
159into your jukebox) some systems prefer to let PAM do this by placing
160a configuration file in /etc/security/ somewhere. See the Fedora Extras
161SRPM source package in case you're interested in how it is handled
162there.
163
164
165If you cannot run hotplugging
166-----------------------------
167
168If you have a distro without hotplugging enabled try this as root:
169
170 % chmod -R a+w /proc/bus/usb
171
172You have to do this again every time you unplug/replug your USB cable
173or restart the jukebox, every time you quit libnjb and restart it,
174etc etc etc an alternative is to run libmtp as root which works just fine.
175The problem is to somehow assure that you (ie the current user) always
176has write access on /proc/bus/usb/*
177
178You can find the Linux hotplug project at:
179http://linux-hotplug.sourceforge.net/
Linus Walleijd3b78572007-08-24 21:28:24 +0000180
181
182Compilation for embedded devices
183--------------------------------
184
185Problems with Autoconf complaining about a missing malloc() function
186during cross-compilation can be solved with this hack if you're using
187glibc:
188
189 % export ac_cv_func_malloc_0_nonnull=yes
190 % ./configure
191
192If you're using uclibc you may have to smack in a custom rpl_malloc()
193function in your program, see the Autoconf texinfo documentation.
194
195See further:
196http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC