Outils pour utilisateurs

Outils du site


tuto:linux:tuto_compilation

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tuto:linux:tuto_compilation [2013/06/05 20:56] – [Exemples] roottuto:linux:tuto_compilation [2013/06/08 17:19] (Version actuelle) – [Exemples] root
Ligne 263: Ligne 263:
 </code> </code>
  
 +  * Include les 2 librairies dans une seule :
  
-Pour transformer un binaire dynamique en statique, il existe des outils comme [[http://sourceforge.net/projects/statifier/files/|ELF Statifier]].+<code c compile6.sh> 
 +#!/bin/bash
  
-Un mini tuto [[http://archive09.linux.com/feature/150677|ici]]. +gcc -c -Wall -Werror -fpic foo.c 
 + 
 +gcc -c -Wall -Werror -fpic boo.c 
 +gcc -shared -o libgigix.so boo.o foo.o 
 + 
 +gcc -L. -Wall -o test main.c -lgigix 
 + 
 +export LD_LIBRARY_PATH=/root/compile 
 +./test 
 + 
 +ldd test 
 +</code> 
 + 
 +<code> 
 +root@ks305337:~/compile# ./6.sh  
 +This is a shared library test... 
 +Hello, I'm a shared library : foo 
 +Hello, I'm a shared library : boo 
 +        linux-vdso.so.1 =>  (0x00007fff2e7fe000) 
 +        libgigix.so => /root/compile/libgigix.so (0x00007fcd2fd37000) 
 +        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcd2f9a3000) 
 +        /lib64/ld-linux-x86-64.so.2 (0x00007fcd2ff3a000) 
 +</code> 
 + 
 +=== Compilation statique === 
 + 
 + 
 +Pour compiler un programme en static (par exemple python) : 
 +<code> 
 +./configure LDFLAGS=" -static  -Wl,-static" CFLAGS=" -static-libgcc -static -march=native -mtune=native -O3 -pipe -fPIC" CC=gcc-4.8 --enable-shared=no 
 +</code> 
 + 
 + 
 + 
 +Pour transformer un binaire dynamique en statique, il existe des outils comme : 
 +  * [[http://sourceforge.net/projects/statifier/files/|ELF Statifier]] : mini [[http://archive09.linux.com/feature/150677|tuto]].  
 +  * [[http://www.magicermine.com/trial.html|Ermine]] : mini [[http://nathanaaron.wordpress.com/2011/08/31/building-a-portable-executable-on-linux/|tuto]]
tuto/linux/tuto_compilation.1370465783.txt.gz · Dernière modification : 2013/06/05 20:56 de root