elf howto 3 6XYER7AFEF3C4BOSQHMBRSS6ANGJGFYOFZMBL2A


The Linux ELF HOWTO: Building programs 3. Building programs 3.1 Ordinary programsTo build a program in ELF, use gcc as always. To build in a.out, use gcc -b i486-linuxaout . $ cat >hello.c main() { printf("hello, world\n"); } ^D $ gcc -o hello hello.c $ file hello hello: ELF 32-bit LSB executable i386 (386 and up) Version 1 $ ./hello hello, worldThis is perhaps an appropriate time to answer the question ``if a.out compilers default to producing a program called a.out, what name does an ELF compiler give its output?''. Still a.out, is the answer. Boring boring boring ... :-)3.2 Building librariesTo build libfoo.so as a shared library, the basic steps look like this: $ gcc -fPIC -c *.c $ gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 *.o $ ln -s libfoo.so.1.0 libfoo.so.1 $ ln -s libfoo.so.1 libfoo.so $ export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATHThis will generate a shared library called libfoo.so.1.0, and the appropriate links for ld (libfoo.so) and the dynamic linker (libfoo.so.1) to find it. To test, we add the current directory to LD_LIBRARY_PATH.When you're happpy that the library works, you'll have to move it to, say, /usr/local/lib, and recreate the appropriate links. Note that the libfoo.so link should point to libfoo.so.1, so it doesn't need updating on every minor version number change. The link from libfoo.so.1 to libfoo.so.1.0 is kept up to date by ldconfig, which on most systems is run as part of the boot process. $ su # cp libfoo.so.1.0 /usr/local/lib # /sbin/ldconfig # ( cd /usr/local/lib ; ln -s libfoo.so.1 libfoo.so )3.3 Building in a.outYou may have a need to continue to build programs in the old a.out format. For `normal' programs all you need to do to use the a.out compiler is specify the flag -b i486-linuxaout when you call gcc, and -m i386linux when (if) you call ld. If you need to build a.out DLL shared libraries still, you have my sympathy. To the best of my knowledge, the short answer is that it doesn't work. Please mail me if you know different. s

Wyszukiwarka

Podobne podstrony:
elf howto 6
elf howto 5
elf howto 1
elf howto 4
elf howto
bootdisk howto pl 8
PPP HOWTO pl 6 (2)
NIS HOWTO pl 1 (2)
kernel howto 3 clbigwpagydoy3epnkmic3ys7wlqwsg4rlwwgvq clbigwpagydoy3epnkmic3ys7wlqwsg4rlwwgvq
consultants howto 18
cdrom howto pl 1
jtz howto pl 5
Keystroke HOWTO pl (2)
PostgreSQL HOWTO pl 14
printing howto pl 5
debian apt howto pl
security howto 7 bif7pmbdlmrob6tcblpvwkf37huqfjqc5eeufry bif7pmbdlmrob6tcblpvwkf37huqfjqc5eeufry
commercial howto 21

więcej podobnych podstron