C - dynamic linked vs. static linked: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 18: | Zeile 18: | ||
/lib64/ld-linux-x86-64.so.2 (0x00007fc8da489000) | /lib64/ld-linux-x86-64.so.2 (0x00007fc8da489000) | ||
</pre> | </pre> | ||
| − | = | + | *ls -lh hello.dynamic |
| + | -rwxr-xr-x 1 root root 17K 18. Sep 18:37 hello.dynamic | ||
| + | |||
| + | =Statisches Kompilieren und linken= | ||
*gcc -Os -static hello.c -o hello.static | *gcc -Os -static hello.c -o hello.static | ||
*./hello.static | *./hello.static | ||
Hallo Welt! | Hallo Welt! | ||
*ldd hello.static | *ldd hello.static | ||
| − | + | not a dynamic executable | |
| + | *ls -lh hello.static | ||
| + | -rwxr-xr-x 1 root root 795K 18. Sep 18:38 hello.static | ||
Aktuelle Version vom 18. September 2022, 20:01 Uhr
Hello World Code in C
#include <stdio.h>
int main(void)
{
puts("Hallo Welt!");
}
Dynamisches Kompilieren
- gcc hello.c -o hello.dynamic
- ./hello.dynamic
Hallo Welt!
- ldd hello.dynamic
linux-vdso.so.1 (0x00007ffdebfc2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc8da2a8000) /lib64/ld-linux-x86-64.so.2 (0x00007fc8da489000)
- ls -lh hello.dynamic
-rwxr-xr-x 1 root root 17K 18. Sep 18:37 hello.dynamic
Statisches Kompilieren und linken
- gcc -Os -static hello.c -o hello.static
- ./hello.static
Hallo Welt!
- ldd hello.static
not a dynamic executable
- ls -lh hello.static
-rwxr-xr-x 1 root root 795K 18. Sep 18:38 hello.static