首页 > 其他 > 详细

gcc生成so文件

时间:2019-11-20 09:16:06      阅读:87      评论:0      收藏:0      [点我收藏+]

准备三个文件test.h, test.c, main.c

test.h

#include <stdio.h>

void say_hello();

test.c

#include "test.h"

void say_hello(char *name){
    printf("hello %s\n", name);
}

main.c

#include "test.h"

int main(){
    say_hello("guanxianseng");

    return 0;
}

执行生成so文件命令

gcc test.c -fPIC -shared -o libtest.so

编译生成main可执行文件

gcc main.c  -L. -ltest -o main

技术分享图片

 

gcc生成so文件

原文:https://www.cnblogs.com/luckygxf/p/11894773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!