Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | |
| 2 | A quick-and-simple guide to installing musl: |
| 3 | |
| 4 | |
| 5 | STEP 1: Configuration |
| 6 | |
| 7 | Edit config.mak to override installation prefix, compiler options, |
Rich Felker | 0b9a1ed | 2011-02-15 14:52:11 -0500 | [diff] [blame] | 8 | target architecture, etc. as needed. Currently supported archs are |
| 9 | i386 and x86_64. Otherwise, the defaults should be okay for trying out |
| 10 | musl with static linking only. |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 11 | |
| 12 | DO NOT set the prefix to /, /usr, or even /usr/local unless you really |
| 13 | know what you're doing! You'll probably break your system such that |
| 14 | you'll no longer be able to compile and link programs against glibc! |
| 15 | This kind of setup should only be used if you're building a system |
| 16 | where musl is the default/primary/only libc. |
| 17 | |
| 18 | The default prefix is /usr/local/musl for a reason, but some people |
| 19 | may prefer /opt/musl or $HOME/musl. |
| 20 | |
Rich Felker | f9c9d8c | 2011-06-27 22:34:47 -0400 | [diff] [blame] | 21 | For shared library support, the dynamic linker pathname needs to be |
| 22 | hard-coded into every program you link to musl. Ideally, you should |
| 23 | leave the path ($syslibdir) set to /lib unless you are unable to |
| 24 | install files to /lib, in which case you can change it. |
| 25 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 26 | |
| 27 | STEP 2: Compiling |
| 28 | |
| 29 | Run "make". (GNU make is required.) |
| 30 | |
| 31 | |
| 32 | STEP 3: Installation |
| 33 | |
| 34 | With appropriate privileges, run "make install". |
| 35 | |
| 36 | |
| 37 | STEP 4: Using the gcc wrapper. |
| 38 | |
| 39 | musl comes with a script "musl-gcc" (installed in /usr/local/bin by |
| 40 | default) that can be used to compile and link C programs against musl. |
| 41 | It requires a version of gcc with the -wrapper option (gcc 4.x should |
| 42 | work). For example: |
| 43 | |
| 44 | cat > hello.c <<EOF |
| 45 | #include <stdio.h> |
| 46 | int main() |
| 47 | { |
| 48 | printf("hello, world!\n"); |
| 49 | return 0; |
| 50 | } |
| 51 | EOF |
| 52 | musl-gcc hello.c |
| 53 | ./a.out |
| 54 | |
| 55 | For compiling programs that use autoconf, you'll need to configure |
| 56 | them with a command like this: |
| 57 | |
| 58 | CC=musl-gcc ./configure |
| 59 | |
| 60 | Be aware that (at present) libraries linked against glibc are unlikely |
| 61 | to be usable, and the musl-gcc wrapper inhibits search of the system |
| 62 | library paths in any case. You'll need to compile any prerequisite |
| 63 | libraries (like ncurses, glib, etc.) yourself. |
Rich Felker | f9c9d8c | 2011-06-27 22:34:47 -0400 | [diff] [blame] | 64 | |
| 65 | Note: If you want the system headers to behave something like glibc's |
| 66 | and expose the kitchen sink by default, you might want to try |
| 67 | CC="musl-gcc -D_GNU_SOURCE" instead of just CC=musl-gcc. This is |
| 68 | needed for compiling many programs with portability issues. |