使用gcc链接共享库 [英] Linking a shared library using gcc

查看:70
本文介绍了使用gcc链接共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows目标上使用Real View编译器工具(RVCT 3.2)创建了一个共享库(* .so).然后,我尝试在Linux系统上使用gcc将* .so文件链接到我的应用程序.

I have a shared library (*.so) created using Real View Compiler Tools (RVCT 3.2) on windows target. Then I try to link this *.so file with my application using gcc on linux system.

将这个共享库与我的应用程序li​​nux链接的gcc选项是什么?

What is the gcc option to link this shared library with my application linux?

我的问题是 -shared 选项是否用作

My question is, is the -shared option, which is used as

gcc -shared myfile.so

...,用于创建SO文件或链接SO文件?我相信它会创建类似的东西:

..., used to create the SO file or to link the SO file? I believe it creates something like:

gcc -lmyfile.so

够了吗?还是有其他任何开关可以告诉链接器它是一个动态库(共享对象)?

Is this enough? Or is there any other switch to tell the linker that it's a dynamic library (shared object)?

推荐答案

对我有用的是:

gcc -L. -l:myfile.so

这篇关于使用gcc链接共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆