The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

Next Previous Contents

6. Compiling with the non-primary libc.

There are times you will want to use an alternate library to compile your programs with. This section explains how to accomplish this, using the directories and installation names used in the examples in the previous two sections. Remember to change the names to fit your setup.

6.1 A warning when using non-primary libcs.

Before compiling any programs which is used in the system boot process, remember that if the program is dynamically linked and is used before the non-root partitions are mounted, all linked libraries must be on the root partition. Following the installation process in the previous section for installing glibc as your primary C library, the old libc is left in /lib, which will be on your root partition. This means all of your programs will still work during booting. However, if /usr is on a different partition and you install glibc as a test library in /usr/i486-linuxglibc2, any new programs you compile with glibc will not work until your /usr partition is mounted.

6.2 Compiling programs with a test glibc.

To compile a program with a test-install glibc, you need to reset the include paths to point to the glibc includes. Specifying "-nostdinc" will negate the normal paths, and "-I/usr/i486-linuxglibc2/include" will point to the glibc includes. You will also need to specify the gcc includes, which are found in /usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include (assuming you installed the test lib in i486-linuxglibc2 with gcc version 2.7.2.2).

To link a program with a test-install glibc, you need to specify the gcc setup. This is done by using the option "-b i486-linuxglibc2".

For most programs, you can specify these new options by adding them to the $CFLAGS and $LDFLAGS makefile options:

 CFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -b i486-linuxglibc2
 LDFLAGS = -b i486-linuxglibc2
 
If you are using a configure script, define the $CFLAGS and $LDFLAGS shell variables (by using env/setenv for csh/tcsh, or set/export for sh/bash/etc) before running configure. The makefiles generated by this should contain the proper $CFLAGS and $LDFLAGS. Not all configure scripts will pick up the variables, so you should check after running configure and edit the makefiles by hand if necessary.

If the programs you are compiling only call gcc (and not cpp or binutils directly), you can use the following script to save having to specify all of the options each time:

 #!/bin/bash
 /usr/bin/gcc -b i486-linuxglibc2 -nostdinc \
              -I/usr/i486-linuxglibc2/include \
              -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include "$@"
 
You can then use this script instead of "gcc" when compiling.

6.3 Compiling programs with libc 5 when glibc is primary library.

To compile a program with your old libraries when you have installed glibc as your main library, you need to reset the include paths to the old includes. Specifying "-nostdinc" will negate the normal paths, and "-I/usr/i486-linuxlibc5/include" will point to the glibc includes. You must also specify "-I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include" to include the gcc specific includes. Remember to adjust these paths based on the what you named the new directories and your gcc version.

To link a program with your old libc, you need to specify the gcc setup. This is done by using the option "-b i486-linuxlibc5".

For most programs, you can specify these new options by appending them to the $CFLAGS and $LDFLAGS makefile options:

 CFLAGS = -nostdinc -I/usr/i486-linuxlibc5/include -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include -b i486-linuxlibc5
 LDFLAGS = -b i486-linuxlibc5
 
If you are using a configure script, define the $CFLAGS and $LDFLAGS shell variables (by using env/setenv for csh/tcsh, or set/export for sh/bash/etc) before running configure. The makefiles generated by this should contain the proper $CFLAGS and $LDFLAGS. Not all configure scripts will pick up the variables, so you should check after running configure and edit the makefiles by hand if necessary.

If the programs you are compiling only call gcc (and not cpp or binutils directly), you can use the following script to save having to specify all of the options each time:

 #!/bin/bash
 /usr/bin/gcc -b i486-linuxlibc5 -nostdinc \
              -I/usr/i486-linuxlibc5/include \
              -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include "$@"
 
You can then use this script instead of "gcc" when compiling.


Next Previous Contents


Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру