그것은 사소한 일입니다. 물론 이것은 정적 라이브러리가 설치되어 있어야 함을 의미합니다. 링커 (종종 cc를 통해 호출 됨)는 둘 다 사용할 수있는 경우 공유 라이브러리를 사용하는 것만으로 기본 설정됩니다.
[[email protected] ~]$ cat hello.c
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
[[email protected] ~]$ cc hello.c -o hello
[[email protected] ~]$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
[[email protected] ~]$ ldd hello
linux-gate.so.1 => (0x00205000)
libc.so.6 => /lib/libc.so.6 (0x00697000)
/lib/ld-linux.so.2 (0x005b4000)
[[email protected] ~]$ cc hello.c -o hello -static
[[email protected] ~]$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, not stripped
[[email protected] ~]$ ldd hello
not a dynamic executable
[[email protected] ~]$ ./hello
Hello, world!
는이 작품을 만들기 위해 내가 glibc는 정적, 기본적으로 설치되지 않습니다 (적어도 Fedora14 인이 상자에) 설치하는 데 필요한. 몇몇 패키지는 ./configure 레벨에서 정적 링크를 선택할 수있게 해 주며 그렇지 않으면 Makefile을 수정해야 할 수도 있습니다.
'./configure --help' - 정적을 찾습니다. – Erik