2009-08-18 7 views

Répondre

2

[email protected]:/tmp$ cat helloworld.c 
#include <stdio.h> 

int main(void) { 
    printf("Hello, world\n"); 
} 
[email protected]:/tmp$ gcc -o helloworld.dyn helloworld.c 
[email protected]:/tmp$ gcc -static -o helloworld.static helloworld.c 
[email protected]:/tmp$ ls -l helloworld.* 
-rw-r--r-- 1 edd edd  69 2009-08-18 07:09 helloworld.c 
-rwxr-xr-x 1 edd edd 6667 2009-08-18 07:10 helloworld.dyn 
-rwxr-xr-x 1 edd edd 576348 2009-08-18 07:10 helloworld.static 
[email protected]:/tmp$ ./helloworld.dyn 
Hello, world 
[email protected]:/tmp$ ./helloworld.static 
Hello, world 
[email protected]:/tmp$ ldd helloworld.static 
     not a dynamic executable 
[email protected]:/tmp$ ldd helloworld.dyn 
     linux-gate.so.1 => (0xb7efc000) 
     libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7d83000) 
     /lib/ld-linux.so.2 (0xb7efd000) 
[email protected]:/tmp$ 
+0

Ne fonctionne pas pour MinGW sous Windows. AFAIK, il n'y a aucun moyen d'échapper à la dépendance sur MSVCRT.DLL en utilisant MinGW, bien que je serais heureux d'avoir tort. –

+0

Ah, oui, cet autre système d'exploitation. Au moins j'en ai deux sur trois couverts. –

+0

J'ai essayé de lier avec un '-static', j'utilise MinGW sur Win7, et il produit 2 fichiers différents (le statique est plus gros de 1.5 Mo). Je ne suis pas expert du tout, mais je pense que ça marche bien ... –

Questions connexes