dynamic link printf instead of include
作者:互联网
we could dynamic symbol printf
with libc.so instead of include<stdio.h> in source file.
a.c
int main(){
printf("hi! .so success!\n");
return 0;}
gcc a.c -lc
a.c: In function ‘main’:
a.c:2:2: warning: implicit declaration of function ‘printf’
[-Wimplicit-function-declaration]
2 | printf("hi! .so success!\n");
| ^~~~~~
a.c:2:2: warning: incompatible implicit declaration of built-in
function ‘printf’
a.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include <stdio.h>
1 | int main(){
./a.out
hi! .so success!
标签:function,main,printf,dynamic,so,link,declaration,instead,include 来源: https://www.cnblogs.com/ijpq/p/15428314.html